Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualfastcall22

Posted 16 September 2013 - 10:04 AM

Cannot figure it out. Any help? Thanks

#include <string>
#include <iostream>

using namespace std;

int main() {
    string str = "world";
    string expr = "Hello, (str)! Expression: (4*2./20)";

    cout << str << endl;
    cout << expr << endl;
}
Outputs:
world
Hello, (str)! Expression: (4*2./20)


And does not output:
world
Hello, world! Expression: 0.4



On the other hand, the following code:
#include <iostream>
#include <sstream>
#include <string>

using namespace std;

int main() {
    string str = "world";
    ostringstream temp;
    temp << "Hello, " << str << "! Expression: " << (4*2./20);
    string expr = temp.str();

    cout << str << endl;
    cout << expr << endl;
}
... does output:
world
Hello, world! Expression: 0.4

#3fastcall22

Posted 16 September 2013 - 10:04 AM

Cannot figure it out. Any help? Thanks

#include <string>
#include <iostream>

using namespace std;

int main() {
    string str = "world";
    string expr = "Hello, (str)! Expression: (4*2./20)";

    cout << str << endl;
    cout << expr << endl;
}
Outputs:
world
Hello, (str)! Expression: (4*2./20)


And does not output:
world
Hello, world! Expression: 0.4



On the other hand, the following code:
#include <iostream>
#include <sstream>
#include <string>

using namespace std;

int main() {
    string str = "world";
    ostringstream temp;
    temp << "Hello, " << str << "! Expression: " << (4*2./20);
    string expr = temp.str();

    cout << str << endl;
    cout << expr << endl;
}
... [i]does[i] output:
world
Hello, world! Expression: 0.4

#2fastcall22

Posted 16 September 2013 - 10:01 AM

Cannot figure it out. Any help? Thanks


#include <string>
#include <iostream>

using namespace std;

int main() {
    string str = "world";
    string expr = "Hello, (str)! Expression: (4*2./20)";

    cout << str << endl;
    cout << expr << endl;
}
Outputs:
world
Hello, (str)! Expression: (4*2./20)


And does not output:
world
Hello, world! Expression: 0.4

#1fastcall22

Posted 16 September 2013 - 10:01 AM

Cannot figure it out. Any help? Thanks


#include <string>
#include <iostream>

using namespace std;

int main() {
    string str = "world";
    string expr = "Hello, (str)! Expression: (4*2./20)";

    cout << str << endl;
    cout << expr << endl;
}
Outputs:
world
Hello, (str)! Expression: (4*2./3)


And does not output:
world
Hello, world! Expression: 0.4

PARTNERS