27 December 2011

C Program to Remove Spaces From the String

Leave a Comment

Program to Remove Spaces From the String






#include<stdio.h>

void main()
{
char a[20];
int i,j,b;
printf("enter the string: ");
gets(a);
for(i=0;a[i]!='\0';i++)
{
if(a[i]==' ')
{
printf("do you want to remove %d blank 1/0:" ,i+1);
scanf("%d",&b);
if(b==1)
{
j=i;
for(; a[j]!='\0';j++)
a[j]=a[j+1];
}
else
continue;
}
}
for(j =0 ; a[j]!='\0';j++)
printf("%c",a[j]);
}

If You Liked This Post Please Take a Time To Share This Post

You May Also Like...

0 comments:

Post a Comment