[Solved] How do i recall a string into a quote?


You are probably looking for string interpolation like for example in PHP or in TypeScript, where you can conveniently write:

const my_variable = 123;
const text = `some text ... ${my_variable} ...`;

Unfortunately, C++ doesn’t have such a feature. There has been a proposal for it, but I don’t think it ever got anywhere.

If the goal is just to print the text, then the safest and easiest way to do so is to split the literal into two parts and print them separately, along with the variable in between:

std::cout << "--- No, " << donorName << ", you cannot donate blood\n";

solved How do i recall a string into a quote?