#include #include #include int main(int argc, char *argv[] ) { char filename[50]; printf("E
Posted: Fri May 20, 2022 12:41 pm
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(int argc, char *argv[] )
{
char filename[50];
printf("Enter the Filename : ");
scanf("%s",&filename);
char line[50];
FILE *fp = fopen( filename, "r");
if (fp == NULL)
{
printf("File opening Unsuccessful\n");
exit(1);
}
else{
printf("File has been open Unsuccessfully\n");
}
while (fgets(line , 30 , fp)
!= NULL)
{
printf(line);
}
fclose(fp) ;
return 0;
}
Write a C program that t expands on the C code
above by reading each of the lines in the file and
displays all the lines read from the file on the screen before
closing it.
The code for this will occur before closing file.
Your program must then output the number of lines in the
file.
To test program, create a text file with at least 5 lines
of text (can be of anything). Use text editor such as
notepad++ to create said text file
#include<stdlib.h>
#include<string.h>
int main(int argc, char *argv[] )
{
char filename[50];
printf("Enter the Filename : ");
scanf("%s",&filename);
char line[50];
FILE *fp = fopen( filename, "r");
if (fp == NULL)
{
printf("File opening Unsuccessful\n");
exit(1);
}
else{
printf("File has been open Unsuccessfully\n");
}
while (fgets(line , 30 , fp)
!= NULL)
{
printf(line);
}
fclose(fp) ;
return 0;
}
Write a C program that t expands on the C code
above by reading each of the lines in the file and
displays all the lines read from the file on the screen before
closing it.
The code for this will occur before closing file.
Your program must then output the number of lines in the
file.
To test program, create a text file with at least 5 lines
of text (can be of anything). Use text editor such as
notepad++ to create said text file