Created
July 15, 2014 09:04
-
-
Save wusuopubupt/64cd0cb29bf67ed82af4 to your computer and use it in GitHub Desktop.
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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int main (void) | |
{ | |
char *string = "T01:91+:123"; | |
char tmp[16]; | |
char* s; | |
/* Strtok can not do with const char*, so I use strncpy copy it to an char array */ | |
strncpy(tmp, string, sizeof(string)); | |
s = strtok (tmp, "T"); | |
printf("string: %s\n", string); // 01:91+:123 | |
s = strtok (s, ":"); | |
printf("city id: %s\n", s); // 01 | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment