jeudi 25 février 2021

Getting an unknown error: operand types are incompatible ("char *" and "char")C/C++(42)

I am currently trying to write a function in c++ that will tell me the number of vowels when characters are inputted. However, I am running into a problem when I try to make if statements that will allow the code to count the vowels. The error is: operand types are incompatible ("char *" and "char")C/C++(42). My equals signs have the red squiggly lines under them meaning there is an error and I'm just not sure what to do to fix it.

The code is not finished by the way I just want to get this error out of the way before I move on.

#include <iostream>
#include <string.h>
#include <cstdio>
using namespace std;


char isVowel(char word , int count) { 
    char word[100];
    int count = 0;
    while (word != '\0') {
        if (word == 'a' || word == 'e' || word == 'i' || word == 'o' || word == 'u') 
        count++;
    }
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire