Converting a String into chars

Im trying to read a string from a file "Test.txt" and then count all of the vocals
and output the number of vocals.But I get a string from the file and it gives an error when i try to read it as an array of chars.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  #include <iostream>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#include <string>

using namespace std;

int main()
{
    int x = 0;

    fstream datei("C:\\Users\\Name\\Desktop\\Test.txt", ios::in);

    char zeile[200];

    for(int i=0;i<201;i++){
            getline(datei,zeile)
        if(zeile=="a"||zeile=="e"||zeile=="i"||zeile=="o"||zeile=="u"){
            x++;
        }
    }
    datei.close();
    cout << x;

    return 0;
}

This part gives me an error:
1
2
3
4
5
6
7
8
for(int i=0;i<201;i++){

            getline(datei,zeile)   <--  This part

        if(zeile=="a"||zeile=="e"||zeile=="i"||zeile=="o"||zeile=="u"){
            x++;
        }
    }
The second argument of getline() is std::string, not char:
http://www.cplusplus.com/reference/string/string/getline/

You could, instead, read the file character by character:
http://www.cplusplus.com/forum/beginner/208134/

And if the incoming character is a vowel then ++x
Topic archived. No new replies allowed.