I am trying to write the beginning part of a program that has to read an array with 10 columns and the rows are not known but they are less than or equal to 150. The program is supposed to exit when a sentinal value of -1 is entered into the first column of whatever row the program is currently reading from. However, I cannot get the while loop to work and was wondering if I could get any help, here is the code I have so far:
Code:
#include <stdio.h>
void ReadArray(int[][10], int, int);
void main(void)
{
int num[3][10];
ReadArray(num, 150, 10);
}
void ReadArray(int num[][10], int numrow, int numcol)
{
int r, c;
for (r=0;r<numrow;r++)
{
for (c=0;c<numcol;c++)
{
while (num[r] != -1)
{
scanf("%d", &num[r][c]);
}
}
}
for (r=0;r<3;r++)
{
for (c=0;c<10;c++)
{
printf("%d ", num[r][c]);
}
}
}