in Education by
This question already has answers here: How to concatenate a std::string and an int (24 answers) Closed 5 years ago. int i = 4; string text = "Player "; cout << (text + i); I'd like it to print Player 4. The above is obviously wrong but it shows what I'm trying to do here. Is there an easy way to do this or do I have to start adding new includes? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
With C++11, you can write: #include // to use std::string, std::to_string() and "+" operator acting on strings int i = 4; std::string text = "Player "; text += std::to_string(i);

Related questions

0 votes
    I am a beginner and I just need a bit of help on why I getline is showing an error: this is what I have so far ... payments[MAX_ITEMS]; ifstream iFile; if ( argc != 2 ) { cout...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I am a beginner and I just need a bit of help on why I getline is showing an error: this is what I have so far ... payments[MAX_ITEMS]; ifstream iFile; if ( argc != 2 ) { cout...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Closed 10 years ago. Possible Duplicate: GNU C++ how to check ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Closed 10 years ago. Possible Duplicate: GNU C++ how to check ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    I doubt it can be done portably, but are there any solutions out there? I think it could be done ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    I want to store the hex values into a string, but I don't know to do that when my string is not giving me the ... using namespace std; int main(){ string s2 = "HelloWorld"; cout...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I want to store the hex values into a string, but I don't know to do that when my string is not giving me the ... using namespace std; int main(){ string s2 = "HelloWorld"; cout...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Generic iterator (3 answers) Closed 7 years ago. Suppose I want to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Generic iterator (3 answers) Closed 7 years ago. Suppose I want to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Generic iterator (3 answers) Closed 7 years ago. Suppose I want to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 15, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Generic iterator (3 answers) Closed 7 years ago. Suppose I want to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 13, 2022 in Education by JackTerrance
+1 vote
    What is the built-in function to append one string to another in C Programming ?...
asked Nov 9, 2020 in Technology by JackTerrance
0 votes
    I want an efficient way to append one string to another in Python. var1 = "foo" var2 = "bar" var3 = var1 + ... built-in method to use? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Concatenate two NumPy arrays vertically (4 answers) Closed 3 years ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Concatenate two NumPy arrays vertically (4 answers) Closed 3 years ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
...