• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

C++ programming help

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.
THANK YOU ALL FOR YOUR HELP! Especially, DaveSimmons.
Finally got it all working. But one quick question, why cant I put a newline in the printf statement just to make it all fit on the screen? not \n, but just in visualStudio
 
Talking about this:

printf("Menu\n1) Hamburger, Fries, and drink...................$2.79\n2) Cheeseburger, Fries, and drink................$3.09\n3) Quarterpounder, Fries and drink...............$3.29\n4) Double Cheesburger, Fries, and drink..........$3.89\n5) Grilled Chicken Sandwich, Fries, and drink....$3.19\n6) Fish Sandwich, Fries, and drink...............$3.29\n");

if you look in the code, it is one long line. Why cant I just press enter and continue it on the next line?
 
Well, at least as I understand it, you can use a carriage return in place of where a space or tab would normally go, except within a quote. You could just split up the printf anywhere you want.

printf("This is a long sen");
printf("tence.\n");
 
You can split them up yourself. Just put a quote at the end of the line and a quote at the next:

printf( "Line one"
"line two"
"Notice no comma between them and only one printf" );

printf("Menu\n"
"1) Hamburger, Fries, and drink...................$2.79\n"
"2) Cheeseburger, Fries, and drink................$3.09\n"
"3) Quarterpounder, Fries and drink...............$3.29\n"
"4) Double Cheesburger, Fries, and drink..........$3.89\n"
"5) Grilled Chicken Sandwich, Fries, and drink....$3.19\n"
"6) Fish Sandwich, Fries, and drink...............$3.29\n");
 
Originally posted by: juiio
You can split them up yourself. Just put a quote at the end of the line and a quote at the next:

printf( "Line one"
"line two"
"Notice no comma between them and only one printf" );

printf("Menu\n"
"1) Hamburger, Fries, and drink...................$2.79\n"
"2) Cheeseburger, Fries, and drink................$3.09\n"
"3) Quarterpounder, Fries and drink...............$3.29\n"
"4) Double Cheesburger, Fries, and drink..........$3.89\n"
"5) Grilled Chicken Sandwich, Fries, and drink....$3.19\n"
"6) Fish Sandwich, Fries, and drink...............$3.29\n");


I guess that works, thanks.
 
Back
Top