Wednesday, 2 June 2021
Write the C program to read the contents of file in.txt and write the co3u contents to a file outext?
Write the C program to read the contents of file in.txt and write the co3u contents to a file outext?
#include
#include // For exit()
int main()
{
FILE *fptr;
char filename[100], c;
printf("Enter the filename to open \n");
scanf("%s", filename);
// Open file
fptr = fopen(filename, "r");
if (fptr == NULL)
{
printf("Cannot open file \n");
exit(0);
}
// Read contents from file
c = fgetc(fptr);
while (c != EOF)
{
printf ("%c", c);
c = fgetc(fptr);
}
fclose(fptr);
return 0;
}
Output:
Enter the filename to open
a.txt
/*Contents of a.txt*/
Subscribe to:
Post Comments (Atom)
C Programming
What is DBMS in brief?
A Database Management System (DBMS) is a software suite designed to efficiently manage, organize, store, manipulate, and retrieve data. It a...
-
Jainism (/ˈdʒeɪnɪzəm/),[1] frequently accustomed as Jain Dharma, is an age-old Indian religion. Jain dharma traces its airy account and hist...
-
A calibration adjudicator is a apparatus for barometer lengths and appointment abstracts at a anchored arrangement of length; two accepted e...
No comments:
Post a Comment