printf function is used to print character stream of data on stdout console.
int printf(const char* str, ...);
int sprintf(char *str, const char *string,...);
String print function instead of printing on console store it on char buffer which are specified in sprintf
Sum of 10 and 20 is 30
fprintf is used to print the string content in file but not on stdout console.
int fprintf(FILE *fptr, const char *str, ...);
Input: GeeksforGeeks GeeksQuiz Output : sample.txt file now having output as 0. GeeksforGeeks 1. GeeksQuiz
Thank you for reading, i will soon update with scanf, fscanf, sscanf keep tuned.
This article is contributed by Vankayala Karunakar. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Nested printf (printf inside printf) in C
- fprintf() in C
- sprintf() in C
- What is use of %n in printf() ?
- Use of & in scanf() but not in printf()
- How to print % using printf()?
- Cin-Cout vs Scanf-Printf
- Execution of printf with ++ operators
- Passing NULL to printf in C
- puts() vs printf() for printing a string
- Return values of printf() and scanf() in C/C++
- How to change the output of printf() in main() ?
- Difference between ++*p, *p++ and *++p
- Difference between C and C++
- Difference between while(1) and while(0) in C language
Improved By : mikerua