Menu

[Solved] Using C Programming Write Program Read Text File Based Command Line Argument Work File Pro Q37226401

Using C Programming

write a program that will read in a text file based on a commandline argument and then work with that file, producing an outputfile.

The command line arguments that your program should take are -h,-i and -o. -i lets the person running specify the input file(default should be input.txt). -o lets the user specify the outputfile (default should be output.txt).

An example of running this project would be, if your executablewas called reverser,

./reverser -i data.in -o data.out

            toread data from the file data.in and send data to data.out

The input file will consist of many lines of numbers, separatedby spaces, with no line longer than 80 characters. An example inputfile would be something like this:

5 17 20 37 8

57 17 17 5 3 9

1 2 3 4 5 6

7 8 1 837 43847

I want you to go through this file, line by line. Starting withthe first number, read it number by number into a stack datastructure that you create. This stack should be implemented using astructure, with a fixed or dynamically allocated array and aninteger storing the location of the topmost element and appropriatefunctions that work with that structure (push, pop). An example ofthis structure would be something similar to:

struct Stack {

    int top;

    int stack[100];

};

Then, using that stack, output the numbers to your output file,again line by line. Treat each line separately. The result shouldbe a file where each output line is the reverse of the input line,with one condition. I want your stack functions to ignoreduplicates. So your stack should, before adding an elementto the stack, ensure that the number is not already in thestack.

Expert Answer


Answer to Using C Programming write a program that will read in a text file based on a command line argument and then work with th… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *