Skip to content

Instantly share code, notes, and snippets.

@shuzo-kino
Created October 17, 2013 09:41
Show Gist options
  • Save shuzo-kino/7022015 to your computer and use it in GitHub Desktop.
Save shuzo-kino/7022015 to your computer and use it in GitHub Desktop.
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