Thanks to both for the help. I went back and changed it to:
1 2 3
|
for(int i= 0; i < MAX_DIGITS; i++){
sNum += (char)number[i]
}
|
Which should fix that problem. Same error. I ran the debugger and it crashes on after line 7 in the code above, where I've placed a leading zero in sNum and return to the beginning of the while loop. It only gets through it once. Here is the output from the debugger:
#0 0x7ffff75543a5 __GI_raise(sig=6) (../nptl/sysdeps/unix/sysv/linux/raise.c:64)
#1 0x7ffff7557b0b __GI_abort() (abort.c:92)
#2 0x7ffff7b90d7d __gnu_cxx::__verbose_terminate_handler() () (/usr/lib/x86_64-linux-gnu/libstdc++.so.6:??)
#3 0x7ffff7b8ef26 ??() (/usr/lib/x86_64-linux-gnu/libstdc++.so.6:??)
#4 0x7ffff7b8ef53 std::terminate() () (/usr/lib/x86_64-linux-gnu/libstdc++.so.6:??)
#5 0x7ffff7b8f04e __cxa_throw() (/usr/lib/x86_64-linux-gnu/libstdc++.so.6:??)
#6 0x7ffff7b3b737 std::__throw_out_of_range(char const*) () (/usr/lib/x86_64-linux-gnu/libstdc++.so.6:??)
#7 0x7ffff7b78d6a std::string::at(unsigned long) () (/usr/lib/x86_64-linux-gnu/libstdc++.so.6:??)
#8 0x4011ff BigNum::BigNum(this=0x7fffffffe3d0, sNum=...) (/win7/Users/neros1x/Dropbox/c_projects/project_euler5/src/BigNum.cpp:10)
#9 0x400da7 main() (/win7/Users/neros1x/Dropbox/c_projects/project_euler5/project_euler5.cpp:11)