Hi,
I have a problem with this program.
The goal of this assignment is to perform rot13 on a string.
The math works fine, and the output is as expected.
After the program converts all of the text, it crashes with an "invalid pointer" error
I think it has something to do with the string?...
(gdb) run
Starting program: /home/j/badCode/a.out
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct NULL not valid
Program received signal SIGABRT, Aborted.
0x00007ffff72dfa75 in *__GI_raise (sig=<value optimised out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
in ../nptl/sysdeps/unix/sysv/linux/raise.c
(gdb) bt
#0 0x00007ffff72dfa75 in *__GI_raise (sig=<value optimised out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1 0x00007ffff72e35c0 in *__GI_abort () at abort.c:92
#2 0x00007ffff7b958e5 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/libstdc++.so.6
#3 0x00007ffff7b93d16 in ?? () from /usr/lib/libstdc++.so.6
#4 0x00007ffff7b93d43 in std::terminate() () from /usr/lib/libstdc++.so.6
#5 0x00007ffff7b93e3e in __cxa_throw () from /usr/lib/libstdc++.so.6
#6 0x00007ffff7b2f9a7 in std::__throw_logic_error(char const*) () from /usr/lib/libstdc++.so.6
#7 0x00007ffff7b71931 in ?? () from /usr/lib/libstdc++.so.6
#8 0x00007ffff7b71a53 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) () from /usr/lib/libstdc++.so.6
#9 0x0000000000400e60 in main () at badcode14.cpp:13
(gdb) up
#1 0x00007ffff72e35c0 in *__GI_abort () at abort.c:92
92 abort.c: No such file or directory.
in abort.c
(gdb) up
#2 0x00007ffff7b958e5 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/libstdc++.so.6
(gdb) up
#3 0x00007ffff7b93d16 in ?? () from /usr/lib/libstdc++.so.6
(gdb) up
#4 0x00007ffff7b93d43 in std::terminate() () from /usr/lib/libstdc++.so.6
(gdb) up
#5 0x00007ffff7b93e3e in __cxa_throw () from /usr/lib/libstdc++.so.6
(gdb) up
#6 0x00007ffff7b2f9a7 in std::__throw_logic_error(char const*) () from /usr/lib/libstdc++.so.6
(gdb) up
#7 0x00007ffff7b71931 in ?? () from /usr/lib/libstdc++.so.6
(gdb) up
#8 0x00007ffff7b71a53 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) () from /usr/lib/libstdc++.so.6
(gdb) up
#9 0x0000000000400e60 in main () at badcode14.cpp:13
13 string z = 0;
and it would all have been clear. I thoroughly recommend gdb or another similar debugger.