我按照书本编译了个程序请看:
/*Illustrates the moduls operatior.*/
/*Inpust a number of seconds,and converts to hours,*/
/*minyres,and seconds.*/
#include<stdio.h>
/*Dedine constants*/
#define SECS_PER_MIN 60
#define SECS_PER_HOUR 3600
unsigned seconds,minutes,hours,secs_left,mins_left;
int main(void)
{
/*Input the number of seconds*/
printf("Enter number of seconds (<6500):");
secanf("%d",&seconds);
hours=seconds/SECS_PER_HOUR;
minutes=seconds/SECS_PER_MIN;
mins_left=minutes%SECS_PER_MIN;
secs_left=seconds%SECS_PER_MIN;
printf("%u seconds is equal to ",seconds);
printf("%u h, %u m, and %u s\n",hours, mins_left, secs_left);
return 0;
}
最后编译不了了,显示:
wangxuyuan@wangxuyuan-laptop:~$ gcc seconds.c -o seconds
/tmp/ccXZfD3j.o: In function `main':
seconds.c:(.text+0x2d): undefined reference to `secanf'
collect2: ld 返回 1
wangxuyuan@wangxuyuan-laptop:~$
这是怎么回事阿,我输入的没有问题阿!
能请大家看看是怎么回事么!
c语言问题
-
- 帖子: 36
- 注册时间: 2007-05-11 19:48
- 来自: 湖北襄樊
这是怎么回事阿能给解释一下阿!
现在又出现了个相似的问题:
/*Demonstrtes the use of if statements*/
#include<stdio.h>
int x,y;
int main(void)
{
/*Input the two values to be tested*/
printf("\nInput an integer value fox x:");
scanf("%d",&x);
printf("\nInput an integer value fox y:");
scanf("%d",&y);
/*Test values and print result*/
if (x==y)
printf("x is equal tu y\n");
if (x>y)
peintf("x is greayer than y\n");
if (x<y)
printf("x is smaller than y\n");
return 0;
}
编译显示:
wangxuyuan@wangxuyuan-laptop:~$ gcc list0403.c -o list0403
/tmp/ccqqAf1K.o: In function `main':
list0403.c:(.text+0x83): undefined reference to `peintf'
collect2: ld 返回 1
wangxuyuan@wangxuyuan-laptop:~$
这个和我上 个问题比较相似,但是就楼上的:
把secanf
改成
scanf
这个说法我这回的编译直接就是scanf阿,怎么不能编译?
现在又出现了个相似的问题:
/*Demonstrtes the use of if statements*/
#include<stdio.h>
int x,y;
int main(void)
{
/*Input the two values to be tested*/
printf("\nInput an integer value fox x:");
scanf("%d",&x);
printf("\nInput an integer value fox y:");
scanf("%d",&y);
/*Test values and print result*/
if (x==y)
printf("x is equal tu y\n");
if (x>y)
peintf("x is greayer than y\n");
if (x<y)
printf("x is smaller than y\n");
return 0;
}
编译显示:
wangxuyuan@wangxuyuan-laptop:~$ gcc list0403.c -o list0403
/tmp/ccqqAf1K.o: In function `main':
list0403.c:(.text+0x83): undefined reference to `peintf'
collect2: ld 返回 1
wangxuyuan@wangxuyuan-laptop:~$
这个和我上 个问题比较相似,但是就楼上的:
把secanf
改成
scanf
这个说法我这回的编译直接就是scanf阿,怎么不能编译?
- BigSnake.NET
- 帖子: 12522
- 注册时间: 2006-07-02 11:16
- 来自: 廣州
- 联系:
- BigSnake.NET
- 帖子: 12522
- 注册时间: 2006-07-02 11:16
- 来自: 廣州
- 联系:
-
- 帖子: 7
- 注册时间: 2008-07-16 13:05