[求助] 请教各位大侠,我的 c 函数哪出问题了,总是有错误
#include <string.h>#include <stdio.h>
void strsplit(char *str, char *by, char *st[])
{
int i=0, n=strlen(str);
char *p;
p = strtok(str, by);
while (p != NULL)
{
strcpy(st[i], p);
p = strtok(NULL, by);
}
return;
}
void main( void )
{
char *string = "y ~ sire + dam + herd + herd*dam, ~ litter + xran";
char *seps = "+";
char **token;
char x[5][30];
*token=x[0];
int i=0;
printf( "%s\n\nTokens:\n", string );
strsplit(string, seps, token);
for (i=0; i<5; i++)
{
printf( " %s\n", x[i] );
}
}