Click here to Skip to main content
15,895,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Ok , I may be asking a silly question but when declaring multiple variables in a console applications for C++.How would I add a space between two int variables and have them print on the same line ? I can get them both to print on the same line but cant seem to add a space.
Posted
Comments
Sergey Alexandrovich Kryukov 25-May-15 12:53pm    
It's not the space between two variables, and not even these values; this is between two strings representing those values.
—SA

C++
cout << variable1 << " " << variable2 << endl;

// or

printf("%d %d\n", variable1, variable2);
 
Share this answer
 
you can do it using printf()[^] or streams[^].
Don't worry, everybody started as a beginner... :D
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 25-May-15 12:54pm    
Sure, a 5.
—SA
Frankie-C 26-May-15 2:54am    
:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900