Reputation: 221
This is my code.
#include <stdio.h>
int main(){
int first;
int second;
int third;
float average=0.0;
printf ("This program will find the average of 3 numbers.\n");
delay(1000);
printf ("Type the first number.\n");
scanf ("%d", &first);
printf ("Type the second number.\n");
scanf ("%d", &second);
printf ("Type the third number.\n");
scanf ("%d", &third);
average = (first+second+third)/2.0;
printf ("The average of %d, %d, and %d is %.3f\n", first, second, third, average);
return (0);
}
When I use gcc to compile it says
Undefined symbols for architecture x86_64:
"_delay", referenced from:
_main in cc62F0GD.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
I am a beginner in coding. What does this mean and how do I fix it?
Upvotes: 0
Views: 1384
Reputation: 2635
EDIT
Since the code is being run on linux environment you can use sleep instead of delay. The header file is unistd.h.
Upvotes: 1
Reputation: 58291
You need to include #include<stdlib.h>
file in your code for delay()
function, its not defined in stdio.h
But I suggest don't use it, instead use what most Unix based operating system suggests unsigned int sleep(unsigned int seconds);
function from #include <unistd.h>
.
Upvotes: 1
Reputation: 1744
Here the error you got is form loader
ld: symbol(s) not found for architecture x86_64
I am not sure but check for the symbol present in your executable.
Use nm command to check the symbole present in your executable.
delay()
in not supported in GCC
use sleep()
http://pubs.opengroup.org/onlinepubs/009695399/functions/sleep.html
Upvotes: 0