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 ?
1 C standard output (printf(), puts() and putchar()) The printf() function sends a formatted string to the standard output (the display). This string can display formatted variables and special control characters, such as new lines ('\n'), backspaces ('\b') and tabspaces ('\t'); these are listed in Table 2.1.
printf() function It prints the given statement to the console. The syntax of printf() function is given below: printf("format string",argument_list);
printf is a function which is defined in stdio. h header file. It will print everything to the screen which is given inside the double quotes.
The printf function (the name comes from “print formatted”) prints a string on the screen using a “format string” that includes the instructions to mix several strings and produce the final string to be printed on the screen.
The correct declaration (ISO/IEC 9899:1999) is:
int printf(const char * restrict format, ... );
But it would be easiest and safest to just #include <stdio.h>
.
Just:
man 3 printf
It will tell you printf
signature:
int printf(const char *format, ...);
this is the right one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With