注册 登录
编程论坛 C++教室

vs2013打开文件的问题

wupeng1988 发布于 2015-01-08 09:03, 508 次点击
#include <stdio.h>

#include <stdlib.h>

int main()

{

    FILE *fp;

    char ch;

    if ((fp = fopen_s("D;\\demo.txt", "w")) == NULL) /* 判断文件是否成功打开 */

    {

        printf("Failure to open demo.txt!\n");

        exit(0);

    }

    ch = getchar();

    while (ch != '\n')   /* 若键入回车换行符则结束键盘输入和文件写入 */

    {

        fputc(ch, fp);

        ch = getchar();

    }

    fclose(fp);           /* 关闭由函数fopen()打开的文件demo.txt */

    return 0;

    system("pause");

}
 /* 判断文件是否成功打开 */那行fopen编译器说有问题
2 回复
#2
wupeng19882015-01-08 09:14
求大神破
#3
rjsp2015-01-08 09:43
你的问题是什么?
或者说,你想叫别人给你解决什么问题?
1