I'll assume this is a homework post and advise anyone else helping to provide concepts and guidance rather than replacement code.
Quote:
Originally Posted by dmckay
//const int maxchar=25;
...
static char name[maxrows][maxcols];
...
//static char name[maxrows][maxchar];
|
Why did you get rid of maxchar and/or please describe more about the shape of the data on which you want to work.
My guess would be you have up to maxrows rows of data and each row has one name made of up to maxchar characters and the name is followed on the row by up to maxcols numbers.
If that is not the shape, what is?
There are two basic approaches to column totals in this situation (code size vs. data size tradeoff).
You need only one variable for row totals because you are done with each row before you start the next.
You could manage with only one variable for column totals
if you arrange for it to be done with each column before starting the next. That requires a second two level nested loop to start after your existing two level nested loop is done (more extra code).
You could manage with just a one level loop of extra code to print the column totals if you accumulate those column totals in an array rather than in a scalar (more data, less code).
Take your choice. Try coding it.