Jump to content
  • Advertisement
Sign in to follow this  
Red Jasper

next line

This topic is 4810 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am very new to c++ and I am trying to make a program that adds up all the ages of my family (because I have nothing better to do all day) and I was just wondering how I could get the text to move onto the next line. E.g. Hello world! Hello computer!

Share this post


Link to post
Share on other sites
Advertisement

#include <iostream>
#include <ostream>

int main() {
std::cout << "Hello, world\n"; // <- \n moves the cursor to the beggining of the next line
std::cout << "Hello, computer";
}


Oxyd

Share this post


Link to post
Share on other sites
You can either add a \n to the string, or if you are using std::cout, you can use endl.

i.e.



printf( "This is text\nThis is on a new line :)");

std::cout << "This is text\nThis is on a new line :)";
std::cout << "This is text" << endl << "This is on a new line :)";



Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!