Alrighty guys, so say I have something like this:

cout <<"hello";
cout <<"how ya doin?";
cout <<"goodbye.";

i know that it is somehow possile to write it something like this:

cout <<"hello";
<<"how ya doin?";
<<"goodbye.";

How would one properly format the block of code with only one cout? I think it has something to do with the semicolons? Any help here?

Thanks!

Recommended Answers

All 2 Replies

How would one properly format the block of code with only one cout? I think it has something to do with the semicolons? Any help here?

By using CODE Tags :icon_twisted:

Since semi's end a statement, don't use them:

cout <<"hello"
     <<"how ya doin?"
     <<"goodbye.";

Or:

cout <<"hello" << "how ya doin?" << "goodbye.";

Or even better:

printf ("Hello! How ya doin? \n Goodbye!")

Printf lets you print your variables without having to keep typing the << " " etc...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.