//if you wrote a string with a number of spaces then this code reduce it to one space only between words.
i marked with a comment the part i didnt understood.
#include <stdio.h>
Code:
int main()
{
char text[100], blank[100];
int c = 0, d = 0;
printf("Enter some text\n");
gets(text);
while (text[c] != '\0')
{
if (!(text[c] == ' ' && text[c+1] == ' ')) {
blank[d] = text[c];
d++; // here, why the program crashes if the c++ were put here.
} //what is the difference.
c++; //c++ here works.
}
blank[d] = '\0';
printf("Text after removing blanks\n%s\n", blank);
return 0;
}