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() ?
- How to print % using printf()?
- Use of & in scanf() but not in printf()
- Cin-Cout vs Scanf-Printf
- Passing NULL to printf in C
- Execution of printf with ++ operators
- How to change the output of printf() in main() ?
- puts() vs printf() for printing a string
- Return values of printf() and scanf() in C/C++
- Difference between C and C#
- Difference between C and C++
- Difference between ++*p, *p++ and *++p
Improved By : mikerua