Search code examples
c++ifstream

C++ - Read char while skipping even lines from file


I have this in my file and I wanted to read only the char and store them in array rankF[26]. My problem is skipping the even lines while reading the file. Any help would be great. Thanks!

enter image description here

This is my current code (without skipping lines):

int a=0;
if (inputFile){
    while(inputFile >> alpha){
        rankF[a] = alpha;
        a++;
    }

Solution

  • Use a string and read the even line in them.

    string noUse;
    int a=0;
    if (inputFile){
        while(inputFile >> alpha){
            rankF[a] = alpha;
            a++;
            inputFile >> noUse;//This will read even lines input.
        }