I wanted to print something using printf() function in C, without including stdio.h, so I wrote program as :
int printf(char *, ...);
int main(void)
{
printf("hello world\n");
return 0;
}
Is the above program correct ?
I have no idea why you'd want to do this.
But it should be const char *.
const char* here.const, but it does not "define a completely different function", only an incorrect prototype for the same function. (I suspect this wrong prototype is actually guaranteed to work anyway, but I'm not sure.)int printf(char *, ...);
works just fine, I don't know why people are telling you that char needs to be a const
const char*. You could just locatestdio.hand read the definition there. Why, out of curiosity, don't you want to#include <stdio.h>?stdio.hdoesn't link anything, header files don't work that way. This question is completely valid, and will work just fine.