请问大家一道c语言的问题,急,我这样编写函数中的内容究竟哪里出错了,为什么运行不了?

#include <stdio.h>
#include <ctype.h>
#include <conio.h>
#include <stdlib.h>
void fun (char *str)
{int i,j=0;
for(i=0;str[i]!='\0';i++)
if(str[i]!='')
str[j++]=str[i];
str[j]='\0';
}
main()
{
char str[81];
char Msg[]="Input a string:";
int n;
FILE *out;
printf(Msg);
gets(str);
puts(str);
fun(str);
printf("*** str: %s\n",str);
/******************************/
out=fopen("out.dat","w");
fun(Msg);
fprintf(out,"%s",Msg);
fclose(out);
/******************************/
}

把fun 函数里的if(str[i]!='')加个空格改成if(str[i]!=' ')就能运行了
温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-03-08
if(str[i]!='')
改为
if(str[i]!=' ')
相似回答