Can anyone help me with a code that reads numbers from a file and puts them into a 2-D Array?
Basically the file has 1000 rows and 2 columns.
For example, a section would look like:
47 56
20 15
20 16
35 76
32 12
So I guess can someone help me understand how to write a code that would put that data into an 2-d array? (if that's even possible) Maybe the first column of numbers into one variable and the second column into the other?
This is the code I used when I tried to even see if I could read the file.
Code:
int main(void)
{
int first_number;
int second_number;
FILE* finput;
finput = fopen("numbers.txt", "r");
do
{
fscanf(finput, "%d %d ", &first_number, &second_number);
printf("%d - %d\n", first_number, second_number);
}while(!feof(finput));
fclose(finput);
system("PAUSE");
return 0;
}
I know this isn't near what I wanted to do, but it sort of worked. Except for some reason it only read a portion of the file.
I think I might be hopeless