C - fputc
File Operations in Tamil

Learn C - C tutorial - C fputc - C examples - C programs
C - fputc() - Definition and Usage
- In C – Programming , the fputc function is used to write the character from the file.

C Syntax
int fputc( int c, FILE * stream );
Sample - C Code
#include <stdio.h>
#include <conio.h>
void main()
{
FILE *fp1;
fp1=fopen("sample.txt","w");
fputc('W',fp1);
fputc('I',fp1);
fputc('K',fp1);
fputc('I',fp1);
fputc('T',fp1);
fputc('E',fp1);
fputc('C',fp1);
fputc('Y',fp1);
getch();
}
C Code - Explanation

- Here in this statement we create a file pointer “fp1”.
- Here in this statement we open the text file using “fopen” function in writing mode.
- In this statement we write the character in the text file using fputc function.
Sample Output - Programming Examples

- Here in this output the statement “WelcomeToWikitechy” in the notepad file (sample.txt) has been shown which is located in the BIN folder of C.
C - putc()
- In C – Programming , Putc function writes the content in the file.
Syntax
putc(“character”, FilePointer)

Sample Code
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp;
char ch;
fp = fopen("one.txt", "w");
printf("Enter data...");
while( (ch = getchar()) != EOF)
{
putc(ch, fp);
}
fclose(fp);
}
Output
