You never change j, it always remains 0, so you're writing every position a[i][0]. atoi(line); will convert the first number in the line only. That's why your program is only storing the first column.
A possible approach to fix this would be something like:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int i=0,totalNums,totalNum,j=0;
size_t count;
int numbers[100][100];
char *line = malloc(100);
FILE *file; /* declare a FILE pointer */
file = fopen("g.txt", "r"); /* open a text file for reading */
while(getline(&line, &count, file)!=-1) {
for (; count > 0; count--, j++)
sscanf(line, "%d", &numbers[i][j]);
i++;
}
totalNums = i;
totalNum = j;
for (i=0 ; i<totalNums ; i++) {
for (j=0 ; j<totalNum ; j++) {
printf("\n%d", numbers[i][j]);
}
}
fclose(file);
return 0;
}
That code will read the entire line, and then parse it number by number until no more numbers are there.
I didn't really understand if input is supposed to be integers or doubles, note that you declare a 2D array of doubles but then you call atoi(). The code I posted assumes it's integers, but then make sure to change your array to a 2D array of ints (or if they really are doubles, change the format string in sscanf).