With C++11, you can write:
#include <string> // to use std::string, std::to_string() and "+" operator acting on strings
int i = 4;
std::string text = "Player ";
text += std::to_string(i);
More Related Contents:
- How do you convert a C++ string to an int? [duplicate]
- What it is the meaning of this error: conversion from ‘char* [40] to non-scalar type ‘std::string
- Converting std::string from const_iterator to char*?
- Pointer to string with spaces [closed]
- std::stoi() takes first number in string?
- How to trim a std::string?
- std::string formatting like sprintf
- How to replace all occurrences of a character in string?
- Legality of COW std::string implementation in C++11
- Alternative to itoa() for converting integer to string C++? [duplicate]
- How to concatenate a std::string and an int
- What’s the difference between size_t and int in C++?
- How to store extremely large numbers?
- Error: invalid operands of types ‘const char [35]’ and ‘const char [2]’ to binary ‘operator+’
- performance of unsigned vs signed integers
- Can a std::string contain embedded nulls?
- cin for an int inputing a char causes Loop that is supposed to check input to go wild
- What does string::npos mean in this code?
- Why don’t the std::fstream classes take a std::string?
- I want to convert std::string into a const wchar_t *
- convert a char* to std::string
- Explicit copy constructor
- Converting an int to std::string
- Why does int8_t and user input via cin shows strange result [duplicate]
- c++ parse int from string [duplicate]
- C++: how to get fprintf results as a std::string w/o sprintf
- Concatenating strings doesn’t work as expected [closed]
- c++ integer->std::string conversion. Simple function?
- Append int to std::string
- C++ concatenate two int arrays into one larger array