hey there... i'm pretty new to c too, but i've had to do a similar thing when i was sending configuration strings to a gps... but anyway, check this out... works for me.
Code:
#include <stdio.h>
#include <string.h>
void main(void)
{
FILE *cfgfile;
int maxline = 256;
int i=0, j=0;
char cfgstring[16][256];
cfgfile = fopen("strings.txt", "r");
if (cfgfile==NULL) printf("can't open file\n");
while (fgets(cfgstring[i], maxline, cfgfile)) { // while not EOF
cfgstring[i][strlen(cfgstring[i])-1] = '\0'; // remove CR from line
i++;
}
for(j=0; j<i; j++) printf(" cfgstring[%d] = [%s]\n", j, cfgstring[j]);
fclose(cfgfile);
}
/*opens this file.... strings.txt
Hello, i am a string
and i am another
the end
*/
/* results on screen
cfgstring[0] = [Hello, i am a string]
cfgstring[1] = [and i am another]
cfgstring[2] = [the end]
*/
this reads each line of the file strings.txt into the two dimensional array cfgstring [16] by [256]... so up to 16 lines stored, and each line can be no more than 256 bytes... although you can make it as big/small as you need
it does however requires that is at least a newline after the final line to be read or it'll remove - in my example - the d in end....
Anyway, thats how i did it.. .hope it helps ya.
Laters