找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2996|回复: 4

[通用编程] 结构的运行问题

[复制链接]
发表于 2007-5-2 20:57:22 | 显示全部楼层 |阅读模式
程序作用: 当系统提问时回答“E”或“e"输入新的记录,回答“L”或"l"时输出已有数据
  1. #include"stdlib.h"
  2. #include"stdio.h"
  3. struct stud_type
  4. {
  5.     char name[20];
  6.     long num;
  7.     int age;
  8.     char sex;
  9.     float score;
  10. }student[30];
  11. int n=0;
  12. main()
  13. {
  14.     char ch;
  15.     int flag=1;
  16.     while(flag)
  17.    {
  18.       printf("\n type 'E'or'e' to enter new record,");
  19.       printf("type 'L' or 'l' to list all records:");
  20.       ch=getchar();getchar();
  21.     switch(ch)
  22.     {
  23.        case 'e':
  24.        case 'E':new_record();break;
  25.        case 'l':
  26.        case 'L':install();break;
  27.        default: flag=0;
  28.     }
  29.   }
  30. }
  31. new_record(void)
  32. {
  33.     char numstr[20];
  34.     printf("\n record %d:\n enter name:",n+1);
  35.     gets(student[n].name);
  36.     printf("\n enter number:");
  37.     gets(numstr);
  38.     student[n].num=atol(numstr);
  39.     printf("\n enter age:");
  40.     gets(numstr);
  41.     student[n].age=atoi(numstr);
  42.     printf("\n enter sex:");
  43.     student[n].sex=getchar();getchar();
  44.     printf("\n enter score:");
  45.     gets(numstr);
  46.     student[n].score=atof(numstr);
  47.     n++;
  48. }
  49. listlall(void)
  50. {
  51.     int i;
  52.     if(n<1)
  53.       printf("\n empty list.\n");
  54.     for(i=0;i<n;i++)
  55.   {
  56.       printf("\nrecord number %d\n",i+1);
  57.       printf("name:%s\n",student[i].name);
  58.       printf("num:%ld\n",student[i].num);
  59.       printf("age:%d\n",student[i].age);
  60.       printf("sex:%c\n",student[i].sex);
  61.       printf("score:%6.2f\n",student[i].score);
  62.   }  
  63. }
复制代码

为什么运行不了呢,要怎么修改才可运行呢?
它的提示错误说明:undefined symbol '_install' in module NONAME.C
发表于 2007-5-2 22:08:28 | 显示全部楼层
作为标准C99,要求在函数的使用前需要进行申明以在后来进行使用.在你使用的过程中两个函数未进行申明,你指出的问题是因为函数明不符的原因
发表于 2007-5-5 12:42:48 | 显示全部楼层
NONAME.C
这个文件是什么呢??
.C文件如果被添加到工程中,会被要求编译通过,偶看LZ没有用到_install的函数,应该要把那个文件移开…… [s:5]
发表于 2007-5-5 19:57:34 | 显示全部楼层
很明显,这位LZ同学是在用TC来写的,所以NONAME.C是TC的命名方式,另外那个什么_install函数是他把名字写错了应该是listlall....... [s:5]
发表于 2007-5-6 15:00:07 | 显示全部楼层
原来是这样啊~~那么就放个声明,在前面,把install改为listall就好了巴^^?

嗯,NONAME.C原来是默认的文件名字
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|幻想森林

GMT+8, 2026-10-30 21:44 , Processed in 0.015066 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表