16年11个月前IP:未同步
194772
4楼
if (fp=fopen("fa.dat","r")==NULL)这样的技巧还是少用为好,编译器通常会提示Warning

另外fopen里第二个参数为r是不能写入内容的


DevC++ 4992 编译通过 运行正常

#include<stdio.h>
#include<stdlib.h>

const char * path = "D:\\\\Users\\\\MiniLight\\\\Desktop\\\\New Text Document.txt";

using namespace std;

int main(int argc, char *argv[])
{
    FILE *fp;
    char ch;

    fp = fopen(path, "wb+");
    if (fp == NULL) {
        printf("Can't open this file!\\n");
        exit(0);
    }

    do {
        ch = getchar();
        fputc(ch, fp);
    }
    while (ch != '@');

    fclose(fp);
    system("[s:9]AUSE");
    return EXIT_SUCCESS;
}

+100
科创币
科创网
2010/02/23
助人为乐。
评论
文号 / 194772

万流景仰
名片发私信
学术分 15
总主题 317 帖总回复 5576 楼拥有证书:进士 学者 机友 笔友
注册于 2008/03/06 02:57:45最后登录 2026/10/20 13:40:53
主体类型:个人
所属领域:无
认证方式:手机号
IP归属地:0

个人简介

Inspiration, Innovation, Discovery

笔记
{{note.content}}
{{n.user.username}}
{{fromNow(n.toc)}} {{n.status === noteStatus.disabled ? "已屏蔽" : ""}} {{n.status === noteStatus.unknown ? "正在审核" : ""}} {{n.status === noteStatus.deleted ? '已删除' : ''}}
  • 编辑
  • 删除
  • {{n.status === 'disabled' ? "解除屏蔽" : "屏蔽" }}
我也是有底线的