arastoo.s
سه شنبه 20 بهمن 1388, 19:58 عصر
سلام من در کار با فابل ها مشکل دارم و نیاز به مثال هالی زیادی در این باره دارم برای همین این پست رو زدم ( که اولین پست من هم هست :لبخندساده:) که هرکی مثالی داره و دوست داره به ما و بقیه دوستان هم یاد بده این جا بزاره تا هم ما یاد بگیریم هم دیگر دوستان
این هم برای شروع کار
//================================================== ===============================
#include <stdio.h>
#include <stdlib.h>
int main(){
FILE *in,*out;
char ch;
in = fopen("/home/arash/A.txt" ,"w");
if (!in) {
printf("\n Can't openning a file .\n");
getchar();
exit(1);
}
printf("\n ENTER >> # << for END . \n");
do {
ch = getchar();
putc(ch,in);
}while (ch != '#');
fclose(in);
out = fopen("/home/arash/Documents/B.txt","w");
if (!out) {
printf("\n Can't openning a file .\n");
getchar();
exit(1);
}
in = fopen("/home/arash/A.txt" ,"r");
if (!in) {
printf("\n Can't openning a file .\n");
getchar();
exit(1);
}
do {
ch =getc(in);
putc(ch,out);
}while (ch != EOF);
fcloseall();
printf("\n file transfered ");
printf("\n\t\t >> Good luck << \t\t\n");
getchar();
return 0;
}
//---------------------------------------
//
// ENTER >> # << for END .
//When day When time WhiteCrow1 comeing back.
//(WhiteCrows1)
//#
//
// file transfered
// >> Good luck <<
//
//---------------------------------------
//================================================== ===============================
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
FILE *fp;
char str[80];
if (!(fp = fopen("test.txt" , "w+"))) {
printf("\n Cant't opening the file . \n");
getchar();
exit(1);
}
printf("\n >> Enter strings ( press ENTER button for end ) <<\n");
while (1) {
gets(str);
if (!(str[0]))
break;
strcat(str,"\n");
fputs(str,fp);
}
rewind(fp);
printf("\n The content of file is : \n\n");
fgets(str,79,fp);
while (!feof(fp)) {
printf("%s" ,str);
fgets(str,79,fp);
}
fclose(fp);
getchar();
return 0;
}
//---------------------------------------
//
// >> Enter strings ( press ENTER button for end ) <<
//This is an example for EDU.
//
//
// The content of file is :
//
//This is an example for EDU.
//
//---------------------------------------
//================================================== ===============================
این هم برای شروع کار
//================================================== ===============================
#include <stdio.h>
#include <stdlib.h>
int main(){
FILE *in,*out;
char ch;
in = fopen("/home/arash/A.txt" ,"w");
if (!in) {
printf("\n Can't openning a file .\n");
getchar();
exit(1);
}
printf("\n ENTER >> # << for END . \n");
do {
ch = getchar();
putc(ch,in);
}while (ch != '#');
fclose(in);
out = fopen("/home/arash/Documents/B.txt","w");
if (!out) {
printf("\n Can't openning a file .\n");
getchar();
exit(1);
}
in = fopen("/home/arash/A.txt" ,"r");
if (!in) {
printf("\n Can't openning a file .\n");
getchar();
exit(1);
}
do {
ch =getc(in);
putc(ch,out);
}while (ch != EOF);
fcloseall();
printf("\n file transfered ");
printf("\n\t\t >> Good luck << \t\t\n");
getchar();
return 0;
}
//---------------------------------------
//
// ENTER >> # << for END .
//When day When time WhiteCrow1 comeing back.
//(WhiteCrows1)
//#
//
// file transfered
// >> Good luck <<
//
//---------------------------------------
//================================================== ===============================
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
FILE *fp;
char str[80];
if (!(fp = fopen("test.txt" , "w+"))) {
printf("\n Cant't opening the file . \n");
getchar();
exit(1);
}
printf("\n >> Enter strings ( press ENTER button for end ) <<\n");
while (1) {
gets(str);
if (!(str[0]))
break;
strcat(str,"\n");
fputs(str,fp);
}
rewind(fp);
printf("\n The content of file is : \n\n");
fgets(str,79,fp);
while (!feof(fp)) {
printf("%s" ,str);
fgets(str,79,fp);
}
fclose(fp);
getchar();
return 0;
}
//---------------------------------------
//
// >> Enter strings ( press ENTER button for end ) <<
//This is an example for EDU.
//
//
// The content of file is :
//
//This is an example for EDU.
//
//---------------------------------------
//================================================== ===============================