Hello, I am making a program in which I am supposed to create a class of string and then try to make functions of the string library.
So, I started off and made the following program (only one function has been defined until now)
The problem that I am getting here is this that the program runs ok. It asks to select the option upon which I press "1" and then it also calls the Constructor (because the cout statement in Constructor executes which shows constructor is working)
However, now, once I enter a string... It just stops there and doesn't go ahead (whereas it should get out of constructor and come back to the main menu). It is apparently not leaving the constructor and I just can't seem to find the problem. Can anyone help me solve this, please?
Thank you very much!
(Here is a sample output.. Program not proceeding once a string is entered)
1 2 3 4
1) Add an Object
2) Find Character at Specified Index
Your Selection: 1
Enter String#1: Hello World
$ g++ -g foo.cpp
$ gdb -q ./a.out
Reading symbols from ./a.out...done.
(gdb) run
Starting program: /home/sc/Documents/a.out
1) Add an Object
2) Find Character at Specified Index
Your Selection: 1
Enter String#1: hello
^C
Program received signal SIGINT, Interrupt.
0x00007ffff756c260 in __read_nocancel () at ../sysdeps/unix/syscall-template.S:84
84 ../sysdeps/unix/syscall-template.S: No such file or directory.
(gdb) bt
#0 0x00007ffff756c260 in __read_nocancel () at ../sysdeps/unix/syscall-template.S:84
#1 0x00007ffff74ef5e8 in _IO_new_file_underflow (fp=0x7ffff78398e0 <_IO_2_1_stdin_>) at fileops.c:592
#2 0x00007ffff74f060e in __GI__IO_default_uflow (fp=0x7ffff78398e0 <_IO_2_1_stdin_>) at genops.c:413
#3 0x00007ffff74eb108 in _IO_getc (fp=0x7ffff78398e0 <_IO_2_1_stdin_>) at getc.c:38
#4 0x00007ffff7b3eb4d in __gnu_cxx::stdio_sync_filebuf<char, std::char_traits<char> >::underflow() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ffff7b4bb21 in std::istream::sentry::sentry(std::istream&, bool) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x00007ffff7b4bd1e in std::istream::operator>>(int&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7 0x0000000000400d76 in main () at foo.cpp:48
(gdb) frame 7
#7 0x0000000000400d76 in main () at foo.cpp:48
48 cin >> choice;
You're back in main, trying to read a choice.
But you're driving blind because the 'what to do' prompt is missing.