I have just started trying to learn C (just got a book on it today) and am having an intractable problem that I am sure is my own idiocy but I can't figure it out. When I try to use the "printf" function I get a compiler problem "implicit declaration of function 'int printf(...)". Also, sometimes when I re-write it it will sometimes work or sometimes just freeze my computer up. I have had to do a hard shut down twice now. I am working in Windows ME and Dev-C++4, could it be that this is yet another example of Windows ME sucking? Any ideas would be appreciated.
Help!
Jeff, Atlanta GA
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It means (most of the time) that you have not given it a definition for a function. Definitions (unless everything is lumped into one file) usualyy come from the header, so if you see that message, check to make sure that you have the right header. Note also that
stdlib.h is not stdio.h
A time or two in the last week, there have been posts from folks trying to include stdin rather than stdio.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thanks wayne - i had tried stdio and stdin, as this book i bought gives one and the program, the other. as i was waiting i stumbled on a site that seems to be leading up to explaining this.
thanks for your patience
jeff
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have just started trying to learn C (just got a book on it today) and am having an intractable problem that I am sure is my own idiocy but I can't figure it out. When I try to use the "printf" function I get a compiler problem "implicit declaration of function 'int printf(...)". Also, sometimes when I re-write it it will sometimes work or sometimes just freeze my computer up. I have had to do a hard shut down twice now. I am working in Windows ME and Dev-C++4, could it be that this is yet another example of Windows ME sucking? Any ideas would be appreciated.
Help!
Jeff, Atlanta GA
Post the code - cut and paste it so that there are no typing errors.
Derek
Sorry - I guess that would have been helpful - here tis, thanks for your help.
#include <stdlib.h>
int main(void)
{
printf("Hello World!\n");
system("PAUSE");
return 0;
}
Am I doing something obviously wrong?
Jeff
Yes, you need to:
#include<stdio.h>
Wayne
Note that when you see something like:
"implicit declaration of function wayneadolt"
It means (most of the time) that you have not given it a definition for a function. Definitions (unless everything is lumped into one file) usualyy come from the header, so if you see that message, check to make sure that you have the right header. Note also that
stdlib.h is not stdio.h
A time or two in the last week, there have been posts from folks trying to include stdin rather than stdio.
Wayne
thanks wayne - i had tried stdio and stdin, as this book i bought gives one and the program, the other. as i was waiting i stumbled on a site that seems to be leading up to explaining this.
thanks for your patience
jeff
Jeff,
Forgive me, as I get confused easily, senility I guess..is your code working for you now?
If not, what does your compile log look like. The following code compiles and runs fine for me with Win98/dev 4.9.7.4/gcc-3.2
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
printf("Hello World!\n");
system("PAUSE");
return 0;
}
Wayne