how do I turn the string integer into an array

1
2
3
4
5
6
7
8
9
10
11
int main ()
{
	string integer1;
	string integer2;

	cout <<" enter your first number: " << endl;
	cin >> integer1;
	cout << endl;
	cout << integer1 << " is your first number" << endl;

}


Now how do I turn the string integer into an array ?
Why do you read it as string?
1
2
3
4
5
6
7
8
9
10
11
12
int main ()
{
	int integer1;
	int integer2;

	cout <<" enter your first number: " << endl;
	cin >> integer1;
	cout << endl;
	cout << integer1 << " is your first number" << endl;

}
Because the largest int value is 2147483647. I need to enter two numbers that are bigger and then sum them up. It's pretty hard, but first step i need to know how to turn a string into an array. Got any ideas ?
std::string in fact is already an array. For example

1
2
3
4
std::string num( "123456789" );

for ( std::string::size_type i = 0; i < num.size(); i++ ) std::cout << num[i];
std::cout << std::endl;

Last edited on
well i get that, but how do you get the num.size? it is a string .

Num1[x]={integer} x is what i want to know
class std::string has member function size()
Topic archived. No new replies allowed.