Finding newlines in C++

Jerry S

So, I've always wondered. How would you go to find a newline in C++?

I know you can find a character within a string like this:

if (strchr(str.c_str(), 'a')) {
    cout << "FOUND IT!";
}

But, how would you go finding a newline like this?:

this is a test[x]
the test is real[x]
keep testing it[x]

So where the [x] are located is where the new line is (assuming the [x] isn't there).

V.moreno

the newline is an special character. The code is '\n', so you should have no problem finding the newline special character. How are you obtaining the strings? If you get them from a file there are functions that return the string with and without the new line character included.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related