这是怎么回事???
#include <stdio.h>#include <stdlib.h>
/*void fen_ge(const char ming_ling[], char jie_guo[]){
const char * p_zi_fu = ming_ling;
int ge_shu = 0; //已经转移的字符个数
//沿前一个参数的数组从前到后寻找字符 ' '
//如果当前字符不是空格就转移
while(' ' != *p_zi_fu){
jie_guo[ge_shu] = *p_zi_fu;
p_zi_fu++;
ge_shu++;
}
jie_guo[ge_shu] = '\0';
}*/
void fen_ge(const char ming_ling[], char **pp_jie_guo){
const char * p_zi_fu = ming_ling;
while(' ' != *p_zi_fu){
p_zi_fu++;
}
*pp_jie_guo = malloc((p_zi_fu - ming_ling + 1) * sizeof(char));
if(*pp_jie_guo){
p_zi_fu = ming_ling;
int ge_shu = 0;
while(' ' != *p_zi_fu){
*(*pp_jie_guo + ge_shu) = *p_zi_fu;
p_zi_fu++;
ge_shu++;
}
*(*pp_jie_guo + ge_shu) = '\0';
}
}
int main() {
char ming_ling[] = "abc def xyz";
/*char jie_guo[20];
fen_ge(ming_ling, jie_guo);*/
char *p_zi_fu =NULL;
fen_ge(ming_ling, &p_zi_fu);
//printf("jie_guo是%s\n",jie_guo);
printf("jie_guo是%s\n",p_zi_fu);
free(p_zi_fu);
return 0;
}
--------------------Configuration: 29whl - Win32 Debug--------------------
Compiling...
29whl.c
G:\C语言编程\WHL\29whl\29whl.c(25) : error C2143: syntax error : missing ';' before 'type'
G:\C语言编程\WHL\29whl\29whl.c(27) : error C2065: 'ge_shu' : undeclared identifier
Error executing cl.exe.
29whl.exe - 2 error(s), 0 warning(s)