Here is my code...
Code:
/*
*/
#include <stdio.h>
#include <conio.h>
void fix(char []);
int main()
{
char str1[81];
printf("Enter text\n");
gets(str1);
fix(str1);
getch();
return 0;
}
void fix(char str1[])
{
char str2[81];
int c = 0, d = 0;
while (str1[c] != '\0')
{
if (!(str1[c] == ' ' && str1[c+1] == ' '))
{
str2[d] = str1[c];
d++;
}
c++;
}
str2[d] = '\0';
printf("The Corrected Text is: \n%s\n", str2);
}
Two things. Would there be a better way to do this without using anything other than stdio.h. Also, can someone please explain to me what this portion of the code does.
Code:
if (!(str1[c] == ' ' && str1[c+1] == ' '))
the "!" is throwing me off. I know what the if statement is doing but when i went to the book i cant find much on the "!" other than i needed it to make my statement work.