| 查看: 2659 | 回复: 12 | ||
| 当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖 | ||
[求助]
谭浩强C语言教材,P298页照着输入都不对!求原因
|
||
|
#include #include #define NULL 0 #define LEN sizeof(struct student) struct student { long num; float score; struct student *next; }; int n; struct student *creat(void) { struct student *head,*p1,*p2; n=0; p1=p2=(struct student *)malloc(LEN); scanf("%ld%f",&p1->num,&p1->score); head=NULL; while(p1->num!=0) { n++; if(n==1) head=p1; else p2->next=p1; p2=p1; p1=(struct student *)malloc(LEN); scanf("%ld%f",&p1->num,&p1->score); } p2->next=NULL; return head; } void main() { struct student *lin1=creat(); } //scanf("%ld%f",&p1->num,&p1->score);好像是这一句出错,但是将float score改成int score就不会出错了,下面的%f相应的改成%d就没错了!真搞不懂了,望高手赐教! |
» 猜你喜欢
求助一下有机合成大神
已经有4人回复
拟解决的关键科学问题还要不要写
已经有8人回复
请教限项目规定
已经有5人回复
最失望的一年
已经有16人回复
存款400万可以在学校里躺平吗
已经有33人回复
求推荐英文EI期刊
已经有5人回复
26申博
已经有3人回复
基金委咋了?2026年的指南还没有出来?
已经有10人回复
基金申报
已经有6人回复
疑惑?
已经有5人回复

11楼2012-03-22 18:48:56
libralibra
至尊木虫 (著名写手)
骠骑将军
- 程序强帖: 40
- 应助: 817 (博后)
- 金币: 12914.1
- 红花: 64
- 帖子: 2238
- 在线: 287.3小时
- 虫号: 696514
- 注册: 2009-02-05
- 专业: 计算机软件

2楼2011-05-06 16:36:12
yalefield
金虫 (文坛精英)
老汉一枚
- 程序强帖: 3
- 应助: 129 (高中生)
- 贵宾: 0.17
- 金币: 21238.9
- 散金: 3440
- 红花: 66
- 帖子: 12101
- 在线: 759.1小时
- 虫号: 96063
- 注册: 2005-10-07
- 专业: 高等教育学
- 管辖: 计算模拟
3楼2011-05-06 22:37:45
holmescn
金虫 (正式写手)
- 程序强帖: 37
- 应助: 1 (幼儿园)
- 金币: 1918.8
- 散金: 275
- 红花: 1
- 帖子: 699
- 在线: 102.6小时
- 虫号: 913482
- 注册: 2009-11-26
- 性别: GG
- 专业: 凝聚态物性 II :电子结构
4楼2011-05-07 08:43:26













回复此楼