Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write A C program called Reverse where it will read from an inputfile in .txt fo

ID: 3599780 • Letter: W

Question

Write A C program called Reverse where it will read from an inputfile in .txt form and write an output file in .txt form

The output file will contain the reversed word order of the input file.

The input file words are separated by one or more spaces ' ' or by horizontal tab ' '

The output file words should be separated by one space.

The input and output files, each line ends with new line character (‘ ’). Lines do not exceed 255 characters including new line character.

An example is shown below

Reverse input output

Input File

Output File

Beside an assault scenario.

When will a friendly cube?

The            precedent.

This percent abides without an arm.

The recipe           multiplies.

The provoking football.

scenario. assault an Beside

cube? friendly a will When

precedent. The

arm. an without abides percent This

multiplies. recipe The

football. provoking The

Input File

Output File

Beside an assault scenario.

When will a friendly cube?

The            precedent.

This percent abides without an arm.

The recipe           multiplies.

The provoking football.

scenario. assault an Beside

cube? friendly a will When

precedent. The

arm. an without abides percent This

multiplies. recipe The

football. provoking The

Explanation / Answer

reverse.c

#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
FILE *fl;   
int counting = 0;
int uu = 0;
if( argc < 2 )
{
printf("Please add sufficient arguments!!! ");
printf("Using "Program_Name Name_of_file" Format_of_File. ");
return -1;
}
fl = fopen(argv[1],"r");
if( fl == NULL )
{
printf(" %s File cannot be opened successfully : ",argv[1]);
return -1;
}
fseek(fl,0,SEEK_END);
counting = ftell(fl);
while( uu < counting )
{
uu++;
fseek(fl,-uu,SEEK_END);
printf("%c",fgetc(fl));
}
printf(" ");
fclose(fl);
return 0;
}

Hence, please follow the format which is needed to be typed in the command line. Hope this helps....

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote