Created
October 17, 2013 09:41
-
-
Save shuzo-kino/7022015 to your computer and use it in GitHub Desktop.
strtokの挙動
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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