File Operations in Tamil


 c-fputc

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 fputc

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

code-explanation-fputc
  1. Here in this statement we create a file pointer “fp1”.
  2. Here in this statement we open the text file using “fopen” function in writing mode.
  3. In this statement we write the character in the text file using fputc function.

Sample Output - Programming Examples

code-explanation-fputc-output
  1. 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)
putc

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

 c-fread

View More Quick Examples


Related Searches to C fputc