請參考getopt - getopt_long - 命令行參數的分析
char * strtok ( char * str, const char * delimiters );
/* strtok example */
#include <stdio.h>
#include <string.h>
int main ()
{
char str[] ="- This, a sample string.";
char * pch;
printf ("Splitting string \"%s\" into tokens:\n",str);
pch = strtok (str," ,.-");
while (pch != NULL)
{
printf ("%s\n",pch);
pch = strtok (NULL, " ,.-");
}
return 0;
}
參考資料:
strtok - C++ Reference
沒有留言:
張貼留言