I am trying to take a numbers from a user and put it into an array without them having to press enter.
i.e the output should look like this
Enter number of rows: 2
Enter number of columns: 3
Enter elements of matrix A:
Enter elements of row1: 2 3 4
Enter elements of row2: 5 2 3
Enter elements of matrix B:
Enter elements of row1: -4 5 3
Enter elements of row2: 5 6 3
Sum of A and B is:
-2 8 7
10 8 6
Currently, my code looks like this,
int main()
{
char *str[100];
int rows, cols;
printf("Enter number of rows: ");
scanf(" %d", &rows);
printf("Enter number of columns: ");
scanf(" %d", &cols);
for(int i = 0; i<rows; i++)
{
printf("Enter elements in row%d: ", i+1);
gets(str[i]);
}
}
Any help would be appreciated, I am still quite new to coding. Thanks!