文字列を区切り文字で分解
#include <stdio.h> #include <string.h> int main() { char s[] = "This is a sentence."; char *p; for (p = strtok(s, " \t\n"); p; p = strtok(NULL, " \t\n")) printf("%s\n", p); return 0; }
C言語では定番の方法。
#include <stdio.h> #include <string.h> int main() { char s[] = "This is a sentence."; char *p; for (p = strtok(s, " \t\n"); p; p = strtok(NULL, " \t\n")) printf("%s\n", p); return 0; }
C言語では定番の方法。