To tylko jedna z 2 stron tej notatki. Zaloguj się aby zobaczyć ten dokument.
Zobacz
całą notatkę
Strtok char *strtok(char *s1, const char *s2); strtok considers the string s1 to consist of a sequence of zero or more text tokens, separated by spans of one or more characters from the separator string s2 The first call to strtok - returns a pointer to the first character of the first token in s1, and - writes a null character into s1 immediately following the returned token Subsequent calls with null for the first argument will work through the string s1 until no tokens remain #include #include int main() { char input[16] = "abc,d"; char *p; /* strtok places a NULL terminator in front of the token, if found */ p = strtok(input, ","); if (p) printf("%s\n", p); /* A second call to strtok using a NULL as the first parameter returns a pointer to the character following the token */ p = strtok(NULL, ","); if (p) printf("%s\n", p); return 0; }
... zobacz całą notatkę
Komentarze użytkowników (0)