Very good.
Compile and everything well, I execute and everything is fine, the problem is that when for example I put a sentence where YES it should tell me at least that there is 1 word that starts with S, the counter follows at 0.
Does someone throw me a cable?
#include <stdio.h>
int main (void) {
int cont;
char c;
printf ("Escribe una frase acabada en punto: ");
scanf ("%c", &c);
cont = 0;
if ((c == 's') || (c == 'S')){
cont = 1;
}
while (c != '.'){
if (c == ' '){
scanf ("%c", &c);
if ((c == 's') || (c == 'S')) {
cont ++;
scanf ("%c", &c);
}
else {
scanf ("%c", &c);
}
scanf ("%c", &c);
}
}
printf ("Hay %d palabras que empiezan por la letra S.\n", cont);
}
In advance, Thanks.