getw
C语言函数名非ANSI标准函数 函数原型int getw(FILE *fp) 函数功能从fp所指向文件读取下一个字整数 返回值返回输入的整数如果文件结束或者出错返回-1 程序举例 #include #include int main(void) { FILE *fp; int num=0,n; if((fp=fopen("D:\\number.txt","w"))==NULL) { printf("Error!\n"); exit(1); } scanf("%d",&num); if(putw(num,fp)==EOF) { printf("Error!\n"); exit(1); } fclose(fp); if((fp=fopen("D:\\number.txt","r"))==NULL) { printf("Error!\n"); exit(1); } if((n=getw(fp))==-1) { printf("Error!\n"); exit(1); } printf("n=%d\n",n); fclose(fp); return 0; }