Question
So, there are two features of bash++ (no its NOT an OO language) that are not supported by bash in general, namely: 1) bash does not allow spaces, tabs or newlines around the "=" symbol used in initialization, and 2) the "then" keyword in bash if statements must be on a different line than the if itself. Also, the brackets ([,]) in bash’s conditionals must have spaces between the bracket and the condition itself. So, the following two statements (legal in bash++) are not acceptable to bash,
num = 0
if [x -lt 5] then ...
Your preprocessor will need to change those two statements (and others like them) in the output to be:
num=0
if [ x -lt 5 ]
then
Again as a "preprocessor" your program will not actually change the input file itself but rather copy the input file to output making the necessary changes to the output file to make it "bashable".
Two items which may seem to you to be choices of the implementation are in fact REQUIRED, namely
1. The program MUST be written in C, not C++ (or java, bash, ruby, …).
2. The name of the bash++ file must be passed to your C program’s executable as command line argument 1. And any command line arguments required for the bash++ program will (must be) passed to your C program’s executable as command line arguments 2 .. n
Solution Preview
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
#include <string.h>#include <stdio.h>
void shiftLeft(int,char *);
void shiftRight(int,char *);
int main(int argc, char **argv)
{
char buffer[800];
int i=0;
int j=0;
int counter = 0;
//int temp=0;
FILE *input;
FILE *output;
//opens the input file
input = fopen(argv[1],"r");
//puts contents of input file into a string
fscanf(input,"%[^EOF]",buffer);
fclose(input);...