[Help] Text file as a 1D or 2D array in C
Hello, my problem is a problem of a bigger program. In this part of a program I have to load a text file which looks like something this::
sta1,sta2,sta3,q3,sta5
a,b,c,d
sta2,sta5,q3
sta1
sta1,a->sta2
sta2,b->sta5
...
Program has to read a file not knowing the number of lines (I made a function for that) and not knowing what's exactly in a file (example: q3,q1,sta2,q4,sta1 instead of the first line of the file)
Is there a way to load that text file as a large 2D array or as multiple 1D arrays (one line = one array)? Something like this:
sta1,sta2,sta3,q3,sta5\0
a,b,c,d\0\0\0\0\0\0\0\0
sta2,sta5,q3\0\0\0\0\0
sta1\0\0\0\0\0\0\0\0\0
sta1,a->sta2\0\0\0\0\0
st2,b->sta5\0\0\0\0\0
etc.
Now, I tell the program to print mat[2][4] and it will print ,
or (second case, 1D arrays) to print r3[6] and it will print -
(I don't need the printing option in my program, I need an different elements from that large array)
I hope you understand what I want to do. I've no idea how to make this or is it even possible. Please, help me. Thanks. :)