Convert intger to string and populate array

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// prompts the user for a non-negative numbers (>= 0)
// reads in the a number and checks
// keeps re-prompting user if the input is invalid (negative)
void input(int& n, int& n1)
{	
		do
		{
			cout << "Please enter a valid non-negative integer:\n";
			cout << "1.";
			cin >> n;
			cout << "2.";
			cin >> n1;
		} while (n <= 0 || n1 <= 0);
	

	//Stores User input integer into a string
	//Dynamically allocates (vertical array) based on string size
	stringstream tmp_stream; 
	tmp_stream << n;
	int SIZE = tmp_stream.str().size();
	int *vArr;
	vArr= new int[SIZE];

	for (int i = 0; i < SIZE; ++i)
	{
		vArr[i] = tmp_stream.str.at(i);
		cout << vArr[i] << setw(12);
	}

How do I go about Populating the elements in the array created, I keep getting a compiler error on this vArr[i] = tmp_stream.str.at(i); but I am a little lost on how to fix.
Well: vArr[i] = tmp_stream.str().at(i);
Topic archived. No new replies allowed.