Hi there,
this code should remove spaces and commas from the string , but I am wondering why the if condition fails to detect the comma and spaces .
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int main(int argc, char **argv)
{
char txt[100];
int i = 0;
strcpy(txt,"the postman, barely made it to the front door.");
while(txt[i] != '.')
{
if(txt[i] != ','|| txt[i] != ' '){
printf("%c",txt[i]);
}
i++;
}
return 0;
}
Result:
the postman, barely made it to the front door
but the output must be like this:
thepostmanbarelymadeittothefrontdoor
but when I try to remove just the comma or spaces it works fine. It must be somthing with the multiple condition in the if statment.