integer to string c++

#include <iostream>
#include <sstream>

int main() {
    int num = 42;  // Step 1: Declare an integer variable and assign a value.

    // Step 2: Create a stringstream object.
    std::stringstream ss;

    // Step 3: Use the stringstream to convert the integer to a string.
    ss << num;

    // Step 4: Use the str() function of the stringstream to get the string representation.
    std::string str_num = ss.str();

    // Step 5: Output the result.
    std::cout << "Integer: " << num << "\nString: " << str_num << std::endl;

    return 0;
}