Code: Select all
abc 10
bgf 20
gfg 68
And I am trying to parse it in C, ending up in segmentation fault (11).
Here's the code:
Code: Select all
char** instruction = malloc(sizeof(char) * 3);
int instructionValue = 0;
while(fscanf(inputFile, "%s %d",instruction,&instructionValue) != EOF)
{
if(strncmp(instruction,"hlt",3) == 0)
{
printf("YEAH!\n");
}
}
fclose(inputFile);
Advertising