Sure, you need to do something along the lines of:
1. Open the file
2. Check if file opened successfully
3. while not EOF
4. reallocate space in array
5. read line into array
6. repeat
7. close file
The file faq is here
To dynamically size the array you need the realloc() function.
Now for multi-dimensional arrays it is a little trickier so here is a quick sample to show you the idea:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main (void)
{
int **myArray;
myArray = (int**)malloc(4 * sizeof(int*));
if(myArray){
for (int i = 0;i < 4;i++)
myArray[i]= (int*)malloc(sizeof(int));
}
for(int i=0;i<4;i++)
for(int j=0;j<4;j++)
myArray[i][j] = 3;
for(int i=0;i<4;i++){
for(int j=0;j<4;j++)
printf("%d", myArray[i][j]);
printf("\n");
}
_getch();
return 0;
}