当前位置: 技术问答>linux和unix
文件读写的问题
来源: 互联网 发布时间:2015-06-15
本文导语: 程序一调试就出问题,编译通过了: FILE *fp; int a=0; if(fp=fopen("test.txt","rw")==NULL) { printf("can't open filen"); return EXIT_SUCCESS; } a=getc(fp); /////调试到了这句就出错了 printf("%dn",a); 错误的提示: gdb...
程序一调试就出问题,编译通过了:
FILE *fp;
int a=0;
if(fp=fopen("test.txt","rw")==NULL)
{
printf("can't open filen");
return EXIT_SUCCESS;
}
a=getc(fp); /////调试到了这句就出错了
printf("%dn",a);
错误的提示:
gdb message:
Program received signal SIGSEGV, Segmentation fault.
我是在kde下写的
FILE *fp;
int a=0;
if(fp=fopen("test.txt","rw")==NULL)
{
printf("can't open filen");
return EXIT_SUCCESS;
}
a=getc(fp); /////调试到了这句就出错了
printf("%dn",a);
错误的提示:
gdb message:
Program received signal SIGSEGV, Segmentation fault.
我是在kde下写的
|
if(fp=fopen("test.txt","rw")==NULL)错。=号优先级最低。
if((fp=fopen("test.txt","rw"))==NULL)
if((fp=fopen("test.txt","rw"))==NULL)