implicit declaration of function 'printf' is invalid in C99

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • john124
    New Member
    • Oct 2012
    • 1

    implicit declaration of function 'printf' is invalid in C99

    I am running Mac OS X Ver. 10.7.5 and when I try to compile this simple program I get this error when I try to fprint to the file:

    implicit declaration of function 'printf' is invalid in C99


    Code:
    #include <stdio.h>
    
    int main()
    {
        FILE *myfile;
        
        myfile = fopen("alive.txt", "w");
        if(!myfile)
        {
            puts("Some kind of file error!");
            return(1);
        }
        
        fprint(myfile, "I created a file! It's alive!\n");
        
        fclose(myfile);
     
        return 0;
    }
    Last edited by zmbd; Oct 21 '12, 03:32 PM. Reason: Please format submitted code using the <CODE/> button.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    I think you meant to code fprintf rather than fprint.

    You must use function prototypes in C99 and the compier coulldn't find one for fprint so it guessed you were using the old-style C method of declaring functions.

    Comment

    Working...