Write a C program using lowlevel io which will read in the f

Write a C program using low-level i/o which will read in the files given on the command line using a buffer of size 1024 and print them to standard out. A sample invocation:
prog2 filea fileb filec filed

Solution

#include <stdio.h>

int main(int argc, char** argv)

// It is good take a double character pointer , so that we can handle dynamic number of file names in input
{
FILE *fp;
int c;
for(int i=1;i<argc;i++){ //Loop through number of file names times
fp = fopen(argv[i],\"r\"); //Open file in read mode
printf(\"\ ************ %s *************\ \",argv[i]);
if (fp) {
while ((c = getc(fp)) != EOF)
putchar(c); //Put the character to stdout
fclose(fp); //Close file after done
}
}
}

Write a C program using low-level i/o which will read in the files given on the command line using a buffer of size 1024 and print them to standard out. A sampl

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site