This commit is contained in:
tTh 2023-09-03 07:49:40 +02:00
parent 9d08631b32
commit b404dde88b

View File

@ -19,7 +19,7 @@ for (foo=0; foo<combien; foo++) {
} }
puts(""); puts("");
for (foo=0; foo<combien; foo++) { for (foo=0; foo<combien; foo++) {
printf(" %c ", isprint(ptr[foo]) ? ptr[foo] : '?'); printf(" %c ", isprint(ptr[foo]) ? ptr[foo] : ' ');
} }
puts(""); puts("");
} }
@ -27,7 +27,7 @@ puts("");
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char input[] = "foo bar quux quiz"; char input[] = "foo bar\tquux wiz";
char *cptr, *copie; char *cptr, *copie;
int foo; int foo;
@ -41,10 +41,15 @@ dump_line("1er strtok", copie, sizeof(input));
printf(" got [%s]\n", cptr); printf(" got [%s]\n", cptr);
puts(""); puts("");
puts(" two more strtok...");
cptr = strtok(NULL, " \t"); cptr = strtok(NULL, " \t");
printf(" got [%s]\n", cptr);
cptr = strtok(NULL, " \t"); cptr = strtok(NULL, " \t");
printf(" got [%s]\n", cptr);
dump_line("2eme & 3me strtok", copie, sizeof(input)); dump_line("2eme & 3me strtok", copie, sizeof(input));
foo = cptr - copie;
foo = cptr - copie; /* this is the hack :) */
printf(" index = %d\n", foo); printf(" index = %d\n", foo);
printf(" and we have [%s]\n", input+foo); printf(" and we have [%s]\n", input+foo);
return 0; return 0;