#include <iostream>
#include <string>
#include <sstream>
int main()
{
constint NUM_DATA = 3;
int data[] = {247, 423, 21};
//stores the result
std::ostringstream result;
//used for converting numbers to strings
std::stringstream numConverter;
//used for storing the string conversions (to be placed in the result)
std::string temp;
for(int i = 0; i < NUM_DATA; i++)
{
if( i != 0 )
{
result << "\r\n"; //carriage return after previous line
}
result << "sd";
//convert the number after "sd" into a string and append to the result
numConverter << (i + 1) << " "; //appending a space to be able to reuse numConverter
numConverter >> temp;
result << temp;
result << ", ";
//convert the piece of data into a string and append to the result
numConverter << data[ i ] << " ";
numConverter >> temp;
result << temp;
}
std::cout << result.str() << std::endl;
return 0;
}