
Originally Posted by
Zhhot
Code:
#include <iostream>
using namespace std;
int main()
{
int length;
length = 7;
cout << "The length is";
cout << length;
system("pause");
return 0;
}
and this is wat i get...
[IMG]http://i961.photobucke*****m/albums/ae94/sami123_photo/untitled-2.jpg[/IMG]
i want the (press any key to continue...) in the second line please help me.
ALSO MODS: CAN U PLEASE MAKE A HELP THREAD AND STICKY IT PLEASE
Well, if you want only the "press any key to continue" to appear on the next line, you can use cout << endl;
For example:
Code:
#include <iostream>
using namespace std;
int main()
{
int length;
length = 7;
cout << "The length is";
cout << length;
cout << endl;
system("pause");
return 0;
}
Or you could do it like this
Code:
#include <iostream>
using namespace std;
int main()
{
int length;
length = 7;
cout << "The length is";
cout << length << endl;
system("pause");
return 0;
}
However if you had a string there is another option, the newline character (\n), for example
Code:
#include <iostream>
using namespace std;
int main()
{
int length;
length = 7;
cout << "Yay random sentence\n";
cout << "Yay thanks to the newline character, i'm by myself\n";
system("pause");
return 0;
}
Everything from the newline character onwards, is put into a new line.
Another example:
Code:
cout << "there is a new\nline in the middle of newline!!";
Would appear in the console as
Code:
there is a new
line in the middle of newline!!