I'm a noob programer. Im tryin to figure out how to pull multiple variables into one line of printf. the code below should be in a sinlge line! i can't crack it! Can anyone HElP?
printf ("The value of number is %c\n", number);
printf ("the value of fraction is %f\n", fraction);
printf ("and the value of letter is %d\n", letter);
std::cout << "The value of number is " << number << '\n' << "the value of fraction is " << fraction << '\n' << "and the value of letter is " << letter << '\n';
It is worth noting that to concatenate literal strings, they just need to be written together. So in:
1 2 3
std::string text = "foo""bar";
std::cout << text << std::endl;
text becomes foobar as the literal strings "foo" and "bar" are concatenated together as they are written together. Any number of white-space chars can separate the literal strings. So
1 2 3 4 5 6 7
std::string text = "foo""bar";
std::cout << text << std::endl;
has the same meaning and text is still foobar. The code displaying: