if(data.peek()=="\n")
I'm trying to use an if statement to break out of a for loop while looking for a end of line statement and that's the code I'm using now but I keep getting compiler error about comparison between a pointer and an integer
FYI: data is an outside text document
so any help would be appreciated
The problem is that data.peek() returns an integer type (and int probably) which is the character peeked. However "\n" is a string and therefore of type char *. You need to use a character constant instead of a string constant,
if(data.peek()=='\n')
Note single quotes instead of double quotes.
If future when asking questions it is important to give all the information. Even in you code listing you have not given the type of data which makes it hard to know if the information I have looked up about peek is true. I have assumed that data is a derivertive of basic_stream.