|
从今天起,我都会把每次学习C的程序,笔记发在这里
原因有二:
一,鼓励自己不要放弃C
二,让大家帮我找找错误,:)
---------文件操作篇----------
[code:1]
#include <stdio.h>
main()
{
FILE *f;
char ch,filename[20];
printf("Input the file you want to write to\n");
scanf("%s",filename);
if((f=fopen(filename,"a"))==NULL)
{printf("Can not open the file\n");
}
printf("Input the strings you want to write,end up with #\n");
ch=getchar();
while(ch!='#')
{fputc(ch,f);
putchar(ch);
ch=getchar();
}
}
[/code:1]
-------------END------------- |
|