首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

怎么用strtok呀

2012-02-06 
如何用strtok呀我的函数是参数是这样的.getrsult(char*usercode,char*key)是对key值做这样的处理,如何做呀

如何用strtok呀
我的函数是参数是这样的.
getrsult(char*   usercode,char*   key)
是对key值做这样的处理,如何做呀
key= "454-45-4545-56-565 ";
如何对key按 "- "分隔把数据存入另个一个数组呀.java中有split,

[解决办法]
// crt_strtok.c
// compile with: /W1
// In this program, a loop uses strtok
// to print all the tokens (separated by commas
// or blanks) in the string named "string ".
//
#include <string.h>
#include <stdio.h>

char string[] = "A string\tof ,,tokens\nand some more tokens ";
char seps[] = " ,\t\n ";
char *token;

int main( void )
{
printf( "Tokens:\n " );

// Establish string and get the first token:
token = strtok( string, seps ); // C4996
// Note: strtok is deprecated; consider using strtok_s instead
while( token != NULL )
{
// While there are tokens in "string "
printf( " %s\n ", token );

// Get next token:
token = strtok( NULL, seps ); // C4996
}
}

热点排行