Menu

[Solved]-Using C Programming Task Project Asked Write Program Read Text File Based Command Line Arg Q37190919

Using C Programming.

Task:

In this project you are being asked to write a program that willread in a text file based on a command line argument and then workwith that file, producing an output file.

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 palin,

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

Details:

You must implement this project using at least 3 source files,reverser.c, stack.h, stack.c, You also must have a makefile thatwill compile the project for me.

In addition, I want you to take a screenshot of you using thedebugger to examine the elements of your stack array in the middleof running your code

Expert Answer


Answer to Using C Programming. Task: In this project you are being asked to write a program that will read in a text file based on… . . .

OR


Leave a Reply

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