The following C++ program does not compile

  • Topic: C/C++ 
  • Thread starter Thread starter soul5
  • Start date Start date
  • Tags Tags
    C++ Program
Join the discussion
Registration is free. Start your own thread to ask a follow-up.
2 replies · 3K views
soul5
Messages
63
Reaction score
0
count << "2 + 3 * 5 = " 2+3*5 << endl;


do I just need to put it as

count << "2 + 3 * 5=" << (2+3*5) << endl;
 
Physics news on Phys.org
soul5 said:
count << "2 + 3 * 5 = " 2+3*5 << endl;do I just need to put it as

count << "2 + 3 * 5=" << (2+3*5) << endl;

First one is bad, second one looks good.

Why don't you simply compile the second, run and test it? ooO, does the second one also throws error?
 
I'm pretty sure you can't mix string output together with variables. You must separate them into with <<.