这段C语言程序为什么运行时显示Debug error和Runtime error?怎么改?(问题截止到2019年3月17日17时00分) 30
4个回答
展开全部
有网友碰到过这样的程序运行显示debug error ,runtime error。。。,问题详细内容为:#include<stdio.h>#include<stdlib.h>intmain(){FILE*fp;structstu{charname[15];charnum[10];floatscore;}student;fp=fopen("info.txt","w");if(fp==NULL){printf("cantopenthefile\...#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE* fp;
struct stu
{
char name[15];
char num[10];
float score;
}student;
fp = fopen("info.txt", "w");
if(fp == NULL)
{
printf("cant open the file\n");
exit(1);
}
printf("input information of student:\n");
printf("name:");
scanf("%s", student.name);
printf("num:");
scanf("%s", student.num);
printf("score:");
scanf("%s", &student.score);
printf("%s %s %7.2f", student.name, student.num, &student.score);
fclose(fp);
return 0;
}展开,我搜你通过互联网收集了相关的一些解决方案,希望对有过相同或者相似问题的网友提供帮助,具体如下:
解决方案1:
scanf("%s", &student.score);
==>
scanf("%f", &student.score);追问输错了,那个地方改了后还是同样的错误追答printf("%s %s %7.2f", student.name, student.num, &student.score);
==>
printf("%s %s %7.2f", student.name, student.num, student.score);
#include <stdlib.h>
int main()
{
FILE* fp;
struct stu
{
char name[15];
char num[10];
float score;
}student;
fp = fopen("info.txt", "w");
if(fp == NULL)
{
printf("cant open the file\n");
exit(1);
}
printf("input information of student:\n");
printf("name:");
scanf("%s", student.name);
printf("num:");
scanf("%s", student.num);
printf("score:");
scanf("%s", &student.score);
printf("%s %s %7.2f", student.name, student.num, &student.score);
fclose(fp);
return 0;
}展开,我搜你通过互联网收集了相关的一些解决方案,希望对有过相同或者相似问题的网友提供帮助,具体如下:
解决方案1:
scanf("%s", &student.score);
==>
scanf("%f", &student.score);追问输错了,那个地方改了后还是同样的错误追答printf("%s %s %7.2f", student.name, student.num, &student.score);
==>
printf("%s %s %7.2f", student.name, student.num, student.score);
展开全部
ydydygugihibucrxfxhvibonifsdibiguzuohivugfyfyfuvjfugbdrydtduftdurdph
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
有网友碰到过这样的程序运行显示debug error ,runtime error。。。,问题详细内容为:#include#includeintmain(){FILE*fp;structstu{charname[15];charnum[10];floatscore;}student;fp=fopen("info.txt","w");if(fp==NULL){printf("cantopenthefile\...#include
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询