删除字符串中的所有空格

删除字符串中的所有空格,如asd af aa z67,则输出asdafaaz67.

#include <stdio.h>
#include <ctype.h>
#include <conio.h>
#include <stdlib.h>
void fun (char *str)
{int i;
char *p;
for(p=str;*p!='\0';p++)
	if(*p!=' ')str[i++]=*p;
  
}
void 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);
  /******************************/
}

猜你喜欢

转载自blog.csdn.net/qq_41496951/article/details/81623655