char - Scanning in more than one word in C -
i trying make program needs scans in more 1 word, , not know how unspecified length. first port of call scanf, scans in 1 word (i know can scanf("%d %s",temp,temporary);, not know how many words needs), looked around , found fgets. 1 issue cannot find how make move next code, eg
scanf("%99s",temp); printf("\n%s",temp); if (strcmp(temp,"edit") == 0) { editloader(); }
would run editloader(), while:
fgets(temp,99,stdin); while(fgets(temporary,sizeof(temporary),stdin)) { sprintf(temp,"%s\n%s",temp,temporary); } if (strcmp(temp,"hi there")==0) { editloader(); }
will not move onto strcmp() code, , stick on original loop. should instead?
i scan in each loop word scanf() , copy strcpy() in "main" string.
Comments
Post a Comment