awdmm 2015-03-29 14:12 采纳率: 0%
浏览 2420

visual studio 2013中freadfwrite的错误

#include "stdafx.h"
#include
#include
struct friends
{
char name[3];
int age;
char sex[3];
int qq;
};
struct friends fri1[2], fri2[2], fr1, *fr2;
int main()
{
fr1 = fri1;
fr2 = fri2;//it is necessary
FILE
fp;
char fname[30];//like can not use
printf("Please input file name\n");
int t=fopen_s(&fp,"D:\Visual Studio 2013\Project\File\freadfwrite1.txt", "wt+");//like can not use fanme ....
printf("t is %d\n", t);
if (t != 0)
{
printf("The file can not be opened");
getchar();
exit(1);//stdlib
}
for (int i = 0; i < 2; i++,fr1++)//fr1++
{
printf("Please input the %dst date name age sex qq\n", i);
printf("hi\n");
scanf_s("%s %d %s %d", fr1 -> name, &fr1 -> age, fr1 -> sex, &fr1 -> qq);//not [] need&
printf("hello\n");
}
for (int i = 0; i < 2; i++, fr2++)
{
printf("name age sex qq");
printf("%s%d%c%d\n", fr1->name, fr1->age, fr1->sex, fr1->qq);//not [] need&
}
fwrite(fr1, sizeof(struct friends), 2, fp);
rewind(fp);//rewind the position
fread(fr2, sizeof(struct friends), 2, fp);
for (int i = 0; i < 2; i++, fr2++)
{
printf("name age sex qq");
printf("%s%d%c%d\n", fr2->name, fr2->age, fr2->sex, fr2->qq);
}
fclose(fp);
return 0;
}图片说明

  • 写回答

3条回答 默认 最新

  • awdmm 2015-03-29 14:14
    关注

    不能运行,在线等回答

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog