Tuesday, July 28, 2009

In C compiler, whats the meaning of "printf should have a prototype " ?

how do i resolve it ? it prevents me from running the program ! Please help

In C compiler, whats the meaning of "printf should have a prototype " ?
printf(); should have a prototype.





its an error message given by C compiler.





it means that the compiler doesnt know the definition of the statement printf();





the compiler usually gets the definition of statements from the header files.(file that ends with .h)





printf() has its prototype in stdio.h , a header file that is used for standard input and output.





if compiler says that printf() doesnt have a prototype, that means u havent included the stdio.h file.





try this program.





#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;





void main()


{


clrscr();


printf("\n hello world");


getch();


}





conio.h(console input and output) is the prototype for getch() and clrscr().
Reply:Sounds like you forgot to #include a header file, probably stdio.h.





Hope that helps.
Reply:Give the Phlebob best answer.





At the top of your file, if you are doing C should be the statement:


#include %26lt;stdio.h%26gt;





or if you are doing C++:


#include %26lt;cstdio%26gt;





without those don't include printf().


No comments:

Post a Comment