Hey everyone, so I have this following code, and what I'm supposed to do is this (assignment copied and pasted below):
Code:The following table shows the total sales for salespeople of the ABC Manufacturing Company. Salesperson Week 1 Week 2 Week 3 Week 4 =============== ====== ====== ====== ====== Nguyen, Michael 25 30 45 20 Johnson, Mary 32 30 33 29 ... The price of the product being sold is $1985.95 (define it as a constant). Write a program that permits the input of the data, up to 25 salespersons and up to 6 weeks, prints a replica of the original table to the screen, and writes to a file a table showing the dollar value of sales for each individual during each week along with his or her total sales. Also it prints the total sales, the lowest and the highest value for each week, and the total sales for the company.so what i've got so far is the names txt. file being inputted and read. Here are the contents of the names.txt file:Code:#include <stdio.h> #define MAX_ROWS 25 #define MAX_COLS 20 int main() { FILE *fp = fopen("names.txt", "r"); char array[25][20] = {0}; int i = 0; int j = 0; int row = 25; int col = 20; if ( fp ) { for ( ;; ) { int c = getc(fp); if ( c == EOF ) { break; } if ( c != '\n' && c != '\r' ) { array[i][j] = c; if ( ++j >= col ) { j = 0; if ( ++i >= row ) { break; } } } } fclose(fp); } for ( i = 0; i < row; i++ ) { for ( j = 0; j < col; j++ ) { putchar(array[i][j]); } putchar('\n'); } return 0; }
I have two questions.Code:16 Kelly, Victor Lam, Gary Nagasake, David Nguyen, Jeff Nguyen, Michael Sinn, Scott Smith, Jacob Son, Thai Tavares, Maribel Tran, Diane Tsukamoto, Andrew Wang, Mary Young, Daniel Wells, Steve Wong, Justin Johnson, Mary
1) How do I skip the first line of the table, in this case, the number 16 at the very top? that number just indicates the number of people there are..I'm supposed to delete that and it's not supposed to be read even thought it's in the txt file. So how do i skip that line?
2) How do I read in 2 .txt files at the same time? When i read in the 2 txt files (names.txt and sales.txt) the output should look like in the assignment above.
see how the two tables are nicely alligned? the names.txt
is on the left and the sales.txt is on the right?
How do i input both files like that and make them alligned to
each other?
btw, the sales.txt file contents are:
Thanks everyone!!!Code:4 25 20 25 25 20 22 23 22 25 26 25 22 30 28 25 26 25 30 45 20 30 25 20 21 27 25 24 26 20 23 24 20 28 26 24 25 30 10 35 32 28 29 30 35 15 16 15 14 12 15 12 19 20 24 20 18 10 15 12 16 32 30 33 29



2Likes
LinkBack URL
About LinkBacks



it keeps on saying that "filename" is undeclared....help please, thanks!!