Two possibilities: on success, it'll return the amount of characters printed. On failure, a negative number is returned.
printf does return the length: size_t len = printf ("%s", str);
== == What is printf in c or prototype of printf with example (q) What is prototype of printf function ? Explain each term. Ans: Prototype of printf function is : int printf( const char *format ,…) Explanation of each term : Parameter of printf function is : (three continuous dots) : It is called ellipsis. It indicates the variable number of arguments. Example of ellipsis: #include void ellipsis(int a,...); void main() { int a=5,b=10; clrscr(); ellipsis(a,b); getch(); } void ellipsis(int a,...) { printf("%d ",a); } Output:5 So printf function can have any number of variables as an argument.
It is a function.
Try this: #include <stdio.h> int main (void) { printf ("printf is at location %p\n", (void *)printf); printf ("main is at location %p\n", (void *)main); return 0; }
int main(int argc, char* argv[]){char a[10],b[10];printf("enter any string\n");scanf("%s",a);printf("a=%s",a);strcpy(b,a);strrev(b);printf("\nb=%s",b);if(strcmp(a,b)==0)printf("\nstring is palindrome");elseprintf("\nnot pelindrome");return 0;}
No, it is a function. But printf does return a value: the number of characters it has written.
int main() { // Call the printf function printf("This is a function call!\n"); return 0; }
Via its name, like: int main (void) { printf ("I'm calling printf right now\n"); return 0; }
Printf function is used in c language. Printf is used to print something to the standard output. ex: printf ('welcome');
it's not a statement, it's a function: len= printf (format, ...more-parameters...);
The print function is slightly more dynamic than the echo function by returning a value, and the echo function is slightly (very slightly) faster. The printf function inserts dynamic variables/whatever into wherever you want with special delimiters, such as %s, or %d. For example, printf('There is a difference between %s and %s', 'good', 'evil') would return 'There is a difference between good and evil'.
printf does return the length: size_t len = printf ("%s", str);
in stdio.h:extern int printf (const char *fmt, ...);
== == What is printf in c or prototype of printf with example (q) What is prototype of printf function ? Explain each term. Ans: Prototype of printf function is : int printf( const char *format ,…) Explanation of each term : Parameter of printf function is : (three continuous dots) : It is called ellipsis. It indicates the variable number of arguments. Example of ellipsis: #include void ellipsis(int a,...); void main() { int a=5,b=10; clrscr(); ellipsis(a,b); getch(); } void ellipsis(int a,...) { printf("%d ",a); } Output:5 So printf function can have any number of variables as an argument.
The printf() function prints a formatted string.
It is a function.
Try this: #include <stdio.h> int main (void) { printf ("printf is at location %p\n", (void *)printf); printf ("main is at location %p\n", (void *)main); return 0; }