在这个程序中,char *token 被初始化为一个奇怪的垃圾值。我无法对其进行排序。这是源代码:
#include<iostream>
#include<string.h>
#include<stdlib.h>
void fetch_value(char *string,int pos,char *dest)
{
char *token;
int i=0;
token=strtok(string,",");
if(pos>1)
{
token=strtok(NULL,",");
while(i<pos-1){
token=strtok(NULL,",");
printf("token =%s\n",token);
i++;
}
strcpy(dest,token);
}
else
{
strcpy(dest,token);
}
}
int main(void)
{
char checking[100];
memset(checking,0x00,sizeof(checking));
fetch_value("14174000100,35679700322,35679700322,35679700322,
35679700322,14174000999,919440710210000,1",0,checking);
printf("checking=%s\n",checking);
return 0;
}
非常感谢您的帮助、反馈或建议。