Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
strtokの挙動
#include <string.h>
#include <stdio.h>
#define SIZE 10
int main() {
int i = 0;
char data[] = "foo bar piyo fuga";
char *argv[SIZE];
argv[i] = strtok(data, " ");
do
{
argv[++i] = strtok(NULL, " ");
} while ( (i < SIZE) && (argv[i] != NULL));
printf("%s\n", argv[0]);
printf("%s\n", argv[1]);
printf("%s\n", argv[2]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment