Question: Starter Code: #include #include #include #include #define ROWS 20 #define COLUMNS 30 int main(int argc, char *argv[]) { char input_table[ROWS][COLUMNS]; ...... int current_row; printf(Enter name

![30 int main(int argc, char *argv[]) { char input_table[ROWS][COLUMNS]; ...... int current_row;](https://s3.amazonaws.com/si.experts.images/answers/2024/09/66e08b097afbe_68966e08b0909447.jpg)
Starter Code:
#include#include #include #include #define ROWS 20 #define COLUMNS 30 int main(int argc, char *argv[]) { char input_table[ROWS][COLUMNS]; ...... int current_row; printf("Enter name age and wage: "); fgets(input_table[current_row], 30, stdin); // add a while(....) { /* need to 'tokenize' the read in line*/ ...... // read again } /* now display the input_table row by row */ .... .... return 0; }
6. Problem E2. 2D array, library functions. Same question as problem E but now you read each line of input as a whole line of string. Note that as discussed earlier, using scanf ("8s", inputArr) does not work here, as scanf stops at the first blank (or new line character). Thus, if you enter Hi there, only Hi is read in. As mentioned in week4's class, in order to read a whole line of input which may contain blanks you can use scanf ("&[~In]s",inputsArr), or, gets (inputsArr), but a much more common approach is to use function fgets ( ) . Both the functions are declared in stdio.h . fgets (inputsArr, n, stdin) reads a maximum of n characters from stdin (Standard input) into inputsArr A file lab4E2.c is created for you to get started. As the code shows, reading a whole line allows the input to be read into a table row directly. So you don't need to store the original input into the table manually. The disadvantage, however, is that you have to tokenize the line in order to get the name, age and wage information. 5.3 Sample Inputs/Outputs: red 307 % a.out Enter name, age and wage: john 60 1.0 Enter name, age and wage: eric 30 1.3 Enter name, age and wage: lisa 22 2.2 Enter name, age and wage: judy 40 3.22 Enter name, age and wage: xxx 2 2 Records generated in lab4E.c on Jan 26 2019 14:58:47 iohn 60 1.00 JOHN 70 1.50 eric 30 1.30 ERIC 40 1.95 lisa 22 2.20 LISA 32 3.30 judy 40 3.22 JUDY 50 4.83 red 308 % You should not hard-code the file name and date time
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
