For example,
Would it be more memory efficient to display these variables like this:
std::cout << "First char is " << char1 << " and second char is " << char2;
rather than this:
std::cout << "First char is " << char1;
std::cout << " and second char is " << char2;
Of course, I’m not literally worried about two lines of code.. But I’m trying to learn to write code more efficiently
Thank you
Having it be a single statement could theoretically be faster as the compiler can rearrange the order of argument evaluation more freely. However, this is talking about 0.00000000000001% difference and is pointless. Don’t care about this – the bottleneck is in the console itself.
Anyway, column alignment is really helpful for readability and so try this:
Or this:
(I prefer the first because I find it easier to format in my text editor).