aop's blog

By aop, history, 7 weeks ago, In English

Can anyone explain what we should prefer "\n" or '\n' for adding a newline character or both are actually the same thing?

 
 
 
 
  • Vote: I like it
  • -37
  • Vote: I do not like it

»
7 weeks ago, # |
  Vote: I like it +11 Vote: I do not like it

Search google first result smh.

»
7 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

I had googled but can't understand the idea. Please if someone knows ,share his idea. Feel free to downvote as most people do to newbie .

  • »
    »
    7 weeks ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    According to what i gathered from the stack overflow thread you can do the following two

    1.> while adding a new line after any numerical datatype use '\n'. example : cout << "age = " << age << '\n'; // more efficient than cout << "age = " << age << "\n";

    2.> If adding a newline after printing a string you can do cout<<"checkoutput \n";

    • »
      »
      »
      7 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Thanks.Now understood the difference.