Skip to content

Instantly share code, notes, and snippets.

@arif98741
Created November 26, 2018 09:34
Show Gist options
  • Save arif98741/b20292e7715dec0311ff16f00d76cb23 to your computer and use it in GitHub Desktop.
Save arif98741/b20292e7715dec0311ff16f00d76cb23 to your computer and use it in GitHub Desktop.
Remove White Space C
#include <stdio.h>
//ariful islam
//github.com/arif98741
int main()
{
char text[1000], blank[1000];
int c = 0, d = 0;
printf("Enter some text\n");
gets(text);
while (text[c] != '\0')
{
if (text[c] == ' ')
{
int temp = c + 1;
if (text[temp] != '\0')
{
while (text[temp] == ' ' && text[temp] != '\0')
{
if (text[temp] == ' ')
{
c++;
}
temp++;
}
}
}
blank[d] = text[c];
c++;
d++;
}
blank[d] = '\0';
printf("Text after removing blanks\n%s\n", blank);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment