2015年3月12日 星期四

[C] Extract tokens from strings

Code :

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define __SEC_POPEN_TOKEN " "

int main(void)
{
    char *ptr;
    char *strtokState;
    char cmdcpy[30] = "Happy Birthday";

    printf("%s \n",(ptr = strtok_r(cmdcpy, __SEC_POPEN_TOKEN, &strtokState)));
}

Execute code :
./a.out 
Happy 

Reference:

Related Posts:

0 意見:

張貼留言