Created
November 26, 2018 09:34
-
-
Save arif98741/b20292e7715dec0311ff16f00d76cb23 to your computer and use it in GitHub Desktop.
Remove White Space C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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