I'm getting multiple errors with attempting to use that method. Should the fgets function be in the format of
Code:
char buf[100];
int BUFSIZ = 100;
fgets(buf, BUFSIZ, fp);
and should the sscanf have the buf as the first argument?
Code:
int num[3];
char words[3];
sscanf(buf, "%d %[^\n]", num[ x ], words[ x ] );
If I try and only do this one time (for the first line) and set x = 0, num[0] should hold 3 and words[0] should hold 'hp psc 2210'
Is this correct?
complete code:
Code:
int num[3];
char words[3];
char buf[100];
int BUFSIZ = 100;
fgets(buf, BUFSIZ, fp);
sscanf(buf, "%d %[^\n]", num[ x ], words[ x ] );
When I try and run this code, I get a segmentation fault. What may I be doing wrong?