jeudi 21 juillet 2016

Reading until '\n' (End of Line)

Firstly, i'm a beginner in C++, be mercyful. I can't find an answer.

Hi, i'm trying to write a interpreter. And i select '\n' as line terminator, when i try this:

#define __TEST__ 1
while(Source >> Word){ //Source is file descriptor. I can't use EOF method because of if i do that, i will need to write two statments. Critical...
    if(Word == '\n'){ // Word is a string object.
        //Clean the vector
#       if __TEST__
            cout << "Succesful!" << "\n";
#       endif       
    }               
}

When i try to compile this code, it's gives an error because of " ' " token. When i change it with ' " ' token, compiler gives no error but when runtime, program can't detect end of line. What is the fastest way of solve this problem?

Aucun commentaire:

Enregistrer un commentaire