#include <stdio.h>
#include <stdlib.h>
#pragma warning (disable : 4996)
void main() {
int matrix[30][50];
int sizeRow, sizeCol;
printf("Number of Rows in your table : ");
scanf("%d", &sizeRow);
printf("Number of Columns in your table : ");
scanf("%d", &sizeCol);
int sum[sizeRow] = { 0 };
for (int row = 0; row < sizeRow; row++){
for (int col = 0; col < sizeCol; col++){
printf("Input element [%d][%d] : ", row, col);
scanf("%d", &matrix[row][col]);
sum[row] += matrix[row][col];
}
}
printf("Total of each row:\n");
for (int row = 0; row < sizeRow; row++){
printf("ROW[%d] SUM :\t%d\n", row, sum[row]);
}
system("pause");
}
I am getting error in the int sum[sizeRow] = { 0 }; where it says that my array should be a constant but the user in my case should determine the array size. Any way I can fix this?
__STDC_NO_VLA__). AFAIK, MS Visual Studio still doesn't support them. GCC and Clang do.