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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Nested printf (printf inside printf) in C
- fprintf() in C
- sprintf() in C
- Return values of printf() and scanf() in C/C++
- How to print % using printf()?
- What is use of %n in printf() ?
- How to change the output of printf() in main() ?
- Passing NULL to printf in C
- Cin-Cout vs Scanf-Printf
- Execution of printf with ++ operators
- Use of & in scanf() but not in printf()
- puts() vs printf() for printing a string
- Difference and Similarities between PHP and C
- Difference Between malloc() and calloc() with Examples
- What is the difference between single quoted and double quoted declaration of char array?
- Difference between "int main()" and "int main(void)" in C/C++?
- Difference between ++*p, *p++ and *++p
- What’s difference between header files "stdio.h" and "stdlib.h" ?
- What is the difference between "char a" and "char a"?
- Difference between getc(), getchar(), getch() and getche()
Improved By : mikerua