int n;
struct Student * creat(void){
struct Student * head;
struct Student * p1,* p2;
n=0;
p1=p2=(struct Student * ) malloc(LEN);
scanf("%1d,%f",&p1->num,&p1->score);
head=NULL;
while(p1->num!=0){
n=n+1;
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct Student *)malloc(LEN);
scanf("%1d,%f",&p1->num,&p1->score);
}
p2->next=NULL;
return(head);
}
第一個scanf 是正常輸入的。但第二個不能,除錯的時候第二個scanf,是直接就過去了,不能執行輸入的功能,這是為啥??
uj5u.com熱心網友回復:
跟蹤除錯是基本技能。uj5u.com熱心網友回復:
搜索一下跟蹤除錯,很容易就會找到問題了。uj5u.com熱心網友回復:
在第二個scanf之前執行一下fflush(stdin),不過也推薦你看一下除錯技巧https://edu.51cto.com/sd/c4099
uj5u.com熱心網友回復:
好的
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/32528.html
標籤:C++ 語言
上一篇:Vs小白求助大神!
下一篇:VS2015,類學習
