mercredi 8 juillet 2020

Whats wrong in the way I defined "Space" in the code?

#include<stdio.h>
#include<stdlib.h>

int main()
{
    setbuf(stdout,NULL);
    char str[100];
    int vow,cons,space,i;
    printf("Enter a sentence: ");
    gets(str);
    for(i=0;str[i]!='\0';i++)
    {
        if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u')
        {
            vow++;
        }
        else if(str[i]=='')/* I am getting an error: empty character constant */
        {
            space++;
        }
        else
        {
            cons++;
        }
    }
    printf("%d%d%d",vow,space,cons);
    return 0;
}

**Please help me how can I add "Space" into the code....I really want to count the spaces between the sentences but isnt this the way to do so? I really cant understand the reason why I am encountering the error...:( **

**I even tried adding space between ' '...still the same issue..

Aucun commentaire:

Enregistrer un commentaire