I'm trying to obtain a large integer (20 characters long) get it from a string then put it into an int array and do the math from there, I'm trying to display the array and I'm getting this
http://i.imgur.com/CI3OTL3.jpg heres my code
#include "stdafx.h"
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
string input1;
string operation;
string input2;
int array1[20];
int array2[20];
cout << "Enter an expression: ";
cin >> input1 >> operation >> input2;
if (input1.length() > 20)
cout << "Invalid Operand (too large). " << endl;
if (input2.length() > 20)
cout << "Invalid Operand (too large). " << endl;
//use array of char
// use subcript and size to keep track of quantity
for (int i = 0; i <= input1.size(); i++)
{
array1[i] = input1[i] - '0';
}
//testing array
for (int i = 0; i <= input1.size(); i++)
{
cout << array1[i];
}
int temp;
//make array stored backwards
for (int i = 0, j = input1.size() - 1; i< input1.size() / 2; i++, j--)
{
temp = array1[i];
array1[i] = array1[j];
array1[j] = temp;
}
cout << "\n backwards:";
for (int i = 0; i <= input1.size(); i++)
{
cout << array1[i];
}