This post will discuss how to convert an int array to a string in C++.

1. Using to_string() function

The idea is to iterate over the array using a for-loop and concatenate all values in an array to a std::string. This can be done using the std::to_string function, which returns the string representation of an integer. This can be implemented as follows:

Download  Run Code

2. Using String Stream

Another option is to use the std::stringstream to concatenate integers to a string. The std::stringstream is a stream class to operate on strings. The basic idea remains the same as above, as shown below:

Download  Run Code

That’s all about converting an int array to a string in C++.