當前位置:編程學習大全網 - 源碼下載 - 這段C語言程序為什麽運行時顯示Debug error和Runtime error?怎麽改?(問題截止到2019年3月17日17時00分)

這段C語言程序為什麽運行時顯示Debug error和Runtime error?怎麽改?(問題截止到2019年3月17日17時00分)

有網友碰到過這樣的程序運行顯示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);

  • 上一篇:幣圈真的要完蛋了嗎?
  • 下一篇:手機APP開發
  • copyright 2024編程學習大全網