C编程问题一些小地方小弟不懂

来源:百度知道 编辑:UC知道 时间:2024/05/10 19:47:39
#include<stdio.h>
main()
{
FILE *fp;
char c1;
if((fp=open("C:\\T.txt","a++"))==NULL)
{
printf("sorry can not open file exit");
getchar();
exit(1);
}

printf("please input string;\n");
c1=getchar();
while(c1!='\n')
{
fputc(c1,fp);
c1=getchar();
}
rewind(fp);
c1=fgetc(fp);
while(c1!=EOF);
{
putchar(c1);
c1=fgetc(fp);
}
printf("\n");
fclose(fp);
}

注:1.if((fp=open("C:\\T.txt","a++"))==NULL)这句中a++是什么意思?
2.rewind是什么意思?
3.还有运行了程序怎么关闭??

a++代表具有读写权限,而且是追加式的
rewind是移动文件指针到文件头的意思
程序在处理完main函数后就会自动退出,当然也就关闭了

跟着长知识了