Menu

newbie problem

2003-02-02
2012-09-26
  • Nobody/Anonymous

    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

     
    • Derek Baker

      Derek Baker - 2003-02-02

      Post the code - cut and paste it so that there are no typing errors.

      Derek

       
    • Nobody/Anonymous

      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

       
    • Nobody/Anonymous

      Yes, you need to:

      #include<stdio.h>

      Wayne

       
    • Nobody/Anonymous

      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

       
    • Nobody/Anonymous

      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

       
    • Nobody/Anonymous

      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

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.