/**
* 有字符串input:"abc ccc faf awre"以空格隔开,
* 要求编写函数实现output:"abc,ccc,faf,awre,"
*
* len为output长度,足够长
* void my_test(const char *input, char *output, int len);
*/
#include
#include
#include
void my_test(const char *input, char *output, int len)
{
char *p;
if (input == NULL || output == NULL) {
return;
}
memset(output, 0, len);
p = strtok(input, " ");
while (p) {
strcat(output, p);
strcat(output, ",");
p = strtok(NULL, " ");
}
printf("%s\n", output);
}
阅读(786) | 评论(0) | 转发(0) |