我看了答案改成了这样,但检查不出哪里有错误
void fun(char *str)
{
int i=0;
char*p=str;
while(*p)
{
if(*p!='')
{
str[i++]=*p;
}
p++;
}
str[i]=0;
回复 叶子:
#include <stdio.h>
#include <ctype.h>
void fun(char *str)
{
int i=0;
char*p=str;
while(*p)
{
if(*p!='')
{
str[i++]=*p;
}
p++;
}
str[i]=0;
}
main()
{
char str[81];void NONO ();
printf("Input a string:") ;
gets(str);
puts(str);
fun(str);
printf("*** str: %s\n",str);
NONO();
}
void NONO ()
{
/* ÇëÔڴ˺¯ÊýÄÚ´ò¿ªÎļþ£¬ÊäÈëµ÷ÊÔÊý¾Ý£¬µ÷Óà fun º¯Êý£¬
Êä³öÊý¾Ý£¬¹Ø±ÕÎļþ¡£ */
char str[81];
int n = 0;
FILE *rf, *wf ;
rf = fopen("in.dat","r") ;
wf = fopen("out.dat","w") ;
while(n < 10) {
fgets(str, 80, rf);
fun(str);
fprintf(wf, "%s", str) ;
n++ ;
}
fclose(rf) ;
fclose(wf) ;
}