0% found this document useful (0 votes)
8 views

File Program

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

File Program

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include<stdio.

h>

#include<conio.h>

#include<ctype.h>

void main( )

char ch;

int lines=0, words=0, characters=0;

printf("Enter any string data: \n");

while((ch=getchar( ))!=EOF)

if(ch==10)

lines++;

if(isspace(ch))

words++;

characters++;

printf("\nTotal Number of Lines : %d", lines+1);

printf("\nTotal Number of Words: %d", words+1);

printf("\nTotal Number of Characters: %d", characters);

#include<stdio.h>

void main()

FILE *fp1,*fp2,*fp3;

char ch;

fp1=fopen("abc.txt","w");

printf("enter the data into file 1\n");

while((ch=getchar())!='.')
putc(ch,fp1);

fclose(fp1);

fp2=fopen("xyz.txt","a");

printf("enter the data into file 2\n");

while((ch=getchar())!='@')

putc(ch,fp2);

fclose(fp2);

fp3=fopen("123.txt","w");

fp1=fopen("abc.txt","r");

while((ch=getc(fp1))!=EOF)

putc(ch,fp3);

fclose(fp1);

fp2=fopen("xyz.txt","r");

while((ch=getc(fp2))!=EOF)

putc(ch,fp3);

fclose(fp2);

fclose(fp3);

printf("the merged files are\t");

fp3=fopen("123.txt","r");

while((ch=getc(fp3))!=EOF)

putchar(ch);

fclose(fp3);

You might also like