I want to take a string and output it without spaces. I wrote the code below but my if statement doesn't seem to detect the spaces in the char string or I am not doing this right.
I assume that my problem is in my if statement but I don't know how to fix it.
int main (void)
{
char s[50];
printf("Enter string:");
fgets(s,50,stdin);
for( int i = 0; i < strlen(s); i++ ){
if( &s[i] != " " ){
printf("%c\n", s[i]);
}
}
return 0;
}
Output:
Enter string:xales was here
x
a
l
e
s
w
a
s
h
e
r
e