How do I use a vector to store a number that's bigger than 2147483647? I'm reading in an insanely large number and manipulating the digits. When the user input is anything above 2147483647 (i.e. 2147483648), it will just stop at 2147483647.
stringstream os;
string st;
//loop through the number of strings (in this case, 4 total strings)
for (int j = 0; j < in; j++) {
os << v.at(j); //converting int 1112 to a string so we can iterate through it
st = os.str(); //store the newly converted string into a string variable
//loop through each individual digit of each string (in this case, 4 digits per string)
//starting from 1 to length-1 to avoid the edges, which we don't care about
for (int k = 1; k < st.length()-1; k++) {
//if current is greater than both neighbors, change that to 'X'
if (st.at(k) > st.at(k+1) && st.at(k) > st.at(k-1)) {
st.at(k) = 'X'; //replace that digit with an 'X'
}
}
cout << st << endl;
os.str(string()); //clears the string in the vector so we can take the next input
os.clear();
@pattrick128 Instead of reading the numbers into a vector<int> and then converting to string why not cut out the middle man and read into a vector<string>?