Thursday, July 9, 2009

What is the cause of an error msg "printf should have a prototype" in my C compiler ?

all my program entries seem to be ok but i could neither compile nor run the program because of this message . What should i do ? pls help

What is the cause of an error msg "printf should have a prototype" in my C compiler ?
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:The prototype is one of the arguments to the printf function. Look up printf in your documentation and see how to use it.
Reply:Did you remember to include the library stdio.h?





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





int main() {


//program


return 0;


}
Reply:i think you missed the header file... do a #include%26lt;stdio.h%26gt;


before the main()...

mothers day flowers

No comments:

Post a Comment