как считать пустое пространство в c - PullRequest
0 голосов
/ 20 января 2020
#include <stdio.h>
#define SIZE 30
int main()
{
    char string1[SIZE];

    printf("%s","Enter a string less than 29 characters");
    scanf("%s",string1);
    int countword=0;
    int countvowel=0;
    int countspace=0;
    int numberofcons;

    for(size_t i=0;i<SIZE;++i){
        if(string1[i]==' '){
            countspace++;
            countword++;
            printf("h");
        }
        if(string1[i]=='a'||string1[i]=='A'||string1[i]=='e'||string1[i]=='E'||string1[i]=='i'||string1[i]=='I'||string1[i]=='o'||string1[i]=='O'||string1[i]=='u'||string1[i]=='U'){
            countvowel=countvowel+1;
            printf("h");
        }
    }
    numberofcons=SIZE-countvowel-countspace;
    printf("Your sentence include\n");
    printf("Number of words:");
    printf("%d\n",countword);
    printf("Number of spaces:");
    printf("%d\n",countspace);
    printf("Number of vowels:");
    printf("%d\n",countvowel);
    printf("Number of consonants and special characters:");
    printf("%d\n",numberofcons);
    printf("%s",string1);
}

так что это моя программа, но почему-то она не работает должным образом. результат показывает, что каждый счетчик, который я пишу, по-прежнему равен 0, и я обнаружил, что входная строка1 читает только до первого пробела, как я могу это исправить

...