How to use .read()

I have a file which I'm reading text from and I'm trying to read the file character by character....I'm using the read function to get the character and it works fine except for when the end of a line is reached it gives me ''. How can I tell me read function to skip this spot in the line? I'm guessing it's a character signaling the end of a line.

Anyway, this is my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
	
for (int i = 0; i < numRows; i++){
    for (int j = 0; j < totalCols; j++){
        char * oneChar;
	oneChar  = new char [1];
	PegType aChar;

	if(!sin.eof()){
	    sin.read(reinterpret_cast<char*>(&aChar), sizeof aChar);
	    peg[i][j] = aChar;
	    cout << "peg " << i <<" " << j<< ":" << peg[i][j] << endl;
	    delete oneChar;
	}
	else 
	    throw exception();
	}
				
}
		


Again, it works fine for the most part, but my array gets messed up because there's a '' character that throws the order off in each line.
closed account (zwA4jE8b)
usually the end of a line character is a '\n'
just put an if statement in there that checks if the char is a '\n'.
if it is, discard it.
That's what I thought too but what I'm getting is just two single quotes with nothing in them (not even white space).
Topic archived. No new replies allowed.