fputc() function in C
![]() |
| fputc() function |
Through this article we will be going to discuss about fputc( ) function of C in which we talk about following topics
- fputc() function in c
- header file for fputc() function in c
- return value of fputc() function in c
- fputc() function in c syntax
- fputc() function in c program
fputc( ) function in C
The fputc() function is nothing but, it is also a standard library function of C which is basically used to write a single character at a time to given file. It write the given character at the position denoted by the file pointer and then advance the file pointer.
Header file for fputc( ) function in C
This file function is define in <stdio.h> which is stand for standard input-output header file.
Return value of fputc( ) function in C
fputc( ) function returns character that is written in the case of successful write operation else in case of error it return EOF is returned.
Syntax of fputc( ) function in C
int fputc(int char , FILE *pointer):
Example of fputc( ) function in C
#include<stdio.h>
#include<stdlib.h>
int main( )
{
FILE *fptr;
int ch;
if((fptr=fopen("myfile.txt","w"))==NULL)
{
printf("File does not exist\n");
exit();
}
else
{
printf ("Enter text:\n");
while((ch=getchar())!=EOF)
fputc(ch,fptr);
}
fclose(fptr);
return 0;
}
___________________________________
![]() |
| Example of fputc( ) |
Conclusion
fputc( ) function of C is used to write a single character at a time in the stream(FILE).

