C Program File Handling/Copy MCA Sem 1

This is a C Programs which copies the content of one file to other (file1.txt to file2.txt). This is a part of Mumbai University MCA Colleges File Handling in C program MCA Sem 1

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main(void)
{
FILE *in, *out;
char ch;
int flag;
clrscr();
if ((in = fopen("C:\\hello\\file1.txt", "rt"))
== NULL)
{
printf("Cannot open input file.\n");
getch();
return;
}

if ((out = fopen("C:\\hello\\file2.txt", "wt"))
== NULL)
{
printf("Cannot open output file.\n");
getch();
return;
}


while (!feof(in))
{
flag=1;
ch=fgetc(in);
ch=toupper(ch);
fputc(ch, out);
}
fclose(in);
fclose(out);
if (flag==1)
{
printf("The File copy is complete\n");
}
getch();
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

No comments:

Post a Comment