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*/

No comments:

Post a Comment

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...