I'm having trouble adding a "0" string to a list of strings in C.
With my current code, I'm having trouble distinguishing between a NULL value and a "0" with my current code. I have tried to debug with the if statement (if(pch == "0")) but when I'm outputting it doesn't go into the if statement.
printf("%c\n",next_line[0]);
pch = strtok(next_line,",");
printf("%s\n",pch);
if(pch == "0"){
printf("NULL VALUE");
strcpy(strs[i],pch);
i++;
pch = strtok(NULL, ",");
}
while(pch != NULL){
strcpy(strs[i],pch);
i++;
pch = strtok(NULL, ",");
}
//go on to print values
the input is: 0,1,03:48:13,9 I never make it past the first character. What can I do to keep my code? Can I maybe change
pch = strtok(NULL, ",");
to pch = strtok(SOMEOTHERVALUE, ",");?
Aucun commentaire:
Enregistrer un commentaire