删除字符串空格
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
#include <stdlib.h>
void fun (char str)
{
int i=0;
char p=str;
while(p)
{
if(p!=' ') /删除空格/
{
str[i]=p;
i++;
}
p++;
}
str[i]='\0'; /加上结束符/
}
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);
/**/
}
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。