Skip to content

Instantly share code, notes, and snippets.

@SohanChy
Created August 8, 2015 20:51
Show Gist options
  • Save SohanChy/fe119b4f656428467c98 to your computer and use it in GitHub Desktop.
Save SohanChy/fe119b4f656428467c98 to your computer and use it in GitHub Desktop.
Remove spaces from string
#include<stdio.h>
#include<string.h>
int main()
{
char xyz[] = "Hey, I have got LOTS of SPACEEEE";
char x[50];
int i=0,j=0;
for(i=0; j<= strlen(xyz);)
{
if( xyz[j] == ' ' && xyz[j+1] == ' ')
{
j++;
}
else
{
x[i] = xyz[j];
i++;
j++;
}
}
puts(x);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment