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.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- 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()?
- Execution of printf with ++ operators
- Passing NULL to printf in C
- Cin-Cout vs Scanf-Printf
- 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 GCC and G++
- Difference between C and C++
- Difference between C and C#
- Difference between ++*p, *p++ and *++p
- Difference between C and Python
- Difference between scanf() and gets() in C
- Difference and Similarities between PHP and C
- Difference between C and Dart
Improved By : mikerua