结构的运行问题
程序作用: 当系统提问时回答“E”或“e"输入新的记录,回答“L”或"l"时输出已有数据#include"stdlib.h"
#include"stdio.h"
struct stud_type
{
char name;
long num;
int age;
char sex;
float score;
}student;
int n=0;
main()
{
char ch;
int flag=1;
while(flag)
{
printf("\n type 'E'or'e' to enter new record,");
printf("type 'L' or 'l' to list all records:");
ch=getchar();getchar();
switch(ch)
{
case 'e':
case 'E':new_record();break;
case 'l':
case 'L':install();break;
default: flag=0;
}
}
}
new_record(void)
{
char numstr;
printf("\n record %d:\n enter name:",n+1);
gets(student.name);
printf("\n enter number:");
gets(numstr);
student.num=atol(numstr);
printf("\n enter age:");
gets(numstr);
student.age=atoi(numstr);
printf("\n enter sex:");
student.sex=getchar();getchar();
printf("\n enter score:");
gets(numstr);
student.score=atof(numstr);
n++;
}
listlall(void)
{
int i;
if(n<1)
printf("\n empty list.\n");
for(i=0;i<n;i++)
{
printf("\nrecord number %d\n",i+1);
printf("name:%s\n",student.name);
printf("num:%ld\n",student.num);
printf("age:%d\n",student.age);
printf("sex:%c\n",student.sex);
printf("score:%6.2f\n",student.score);
}
}
为什么运行不了呢,要怎么修改才可运行呢?
它的提示错误说明:undefined symbol '_install' in module NONAME.C 作为标准C99,要求在函数的使用前需要进行申明以在后来进行使用.在你使用的过程中两个函数未进行申明,你指出的问题是因为函数明不符的原因 NONAME.C
这个文件是什么呢??
.C文件如果被添加到工程中,会被要求编译通过,偶看LZ没有用到_install的函数,应该要把那个文件移开…… 很明显,这位LZ同学是在用TC来写的,所以NONAME.C是TC的命名方式,另外那个什么_install函数是他把名字写错了应该是listlall....... 原来是这样啊~~那么就放个声明,在前面,把install改为listall就好了巴^^?
嗯,NONAME.C原来是默认的文件名字
页:
[1]