Skip to content

Instantly share code, notes, and snippets.

@kjunichi
Created December 18, 2023 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjunichi/1b4afd604050025d86047824370597fd to your computer and use it in GitHub Desktop.
Save kjunichi/1b4afd604050025d86047824370597fd to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
int main() {
char *test_str="ou=Groups,dc=lan_ab,dc=co,dc=jp:cn=jun:123";
char buf[1024];
char *tmpStr;
char param[10][1024];
int cnt;
memset(buf, 0x00, sizeof(buf));
strcpy(buf, test_str);
printf("buf = %s\n", buf);
tmpStr = strtok(buf, ":");
printf("buf = %s\n", buf);
printf("tmpStr = %s\n", tmpStr);
cnt=0;
strcpy(param[cnt], tmpStr);
for(cnt=1; cnt <3; cnt++) {
tmpStr = strtok(NULL, ":");
strcpy(param[cnt], tmpStr);
}
for(cnt=0; cnt < 3;cnt++) {
printf("param[%d] = %s\n", cnt, param[cnt]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment