快捷导航

C语言文件的输入输出:为什么我文件操作类型是r+,但不能同时读写???

#include #include #include int main(){        FILE *fp;        int i=7;        char *s,m[20]="hello\0";fp=fopen("student.txt","r+");if(fp==NULL){                printf("empty!!");        }else{                printf("file has been open\n") ;                fputs("youcan",fp);fprintf(fp,"%d",i);        fgets(m,2,fp);        printf("%s",m);fclose(fp);}        return 0;        }这样我运行就没有输出,但是如果我注释掉写入文件的部分,就能正常文件输出

免责声明:本内容仅代表回答者见解不代表本站观点,请谨慎对待。

版权声明:作者保留权利,不代表本站立场。

回复

使用道具 举报

参与会员2

蟹妖,编译报错了吗?文件放在和源程序同一目录内了吗?你检查下url的地址是否正确吧。
回复

使用道具 举报

“rw”
回复

使用道具 举报

可能感兴趣的问答

发新帖
  • 微信访问
  • 手机APP