D
davinci
I had study it for a long time .but I didn't solve it .Ihad read
<<Debuging with GDB>>
But I didn't get something useful.
include<iostream>
#include<cstdlib>
using std::isdigit;
int main()
{ int i=4;
try
{
while(1)
{
std::cin>>i;
if(!isdigit(i))
{
std::cout<<"not digit ,once more"<<std::endl;
std::cout<<"i="<<i<<std::endl;
}
if(i==2)
{
std::cout<<"good boy"<<std::endl;
}
else
{
std::cout<<"bad boy"<<std::endl;
}
}
}
catch(...)
{
std::cout<<"execption had happened"<<std::endl;
}
}
//end of the codes
//from here: std::cin>>i;
(gdb) s //here ,no chance to input anything.
(gdb) s
(gdb) s
not digit ,once more
(gdb) s
i=4
(gdb) s
(gdb) s
bad boy
(gdb) s //no chance to input anything,there is no prompt for input.
(gdb) s
(gdb) s
not digit ,once more
(gdb) s
i=4
(gdb)
But I can input something when I am no in the main function.
anyhelp?
thanks very much.
<<Debuging with GDB>>
But I didn't get something useful.
include<iostream>
#include<cstdlib>
using std::isdigit;
int main()
{ int i=4;
try
{
while(1)
{
std::cin>>i;
if(!isdigit(i))
{
std::cout<<"not digit ,once more"<<std::endl;
std::cout<<"i="<<i<<std::endl;
}
if(i==2)
{
std::cout<<"good boy"<<std::endl;
}
else
{
std::cout<<"bad boy"<<std::endl;
}
}
}
catch(...)
{
std::cout<<"execption had happened"<<std::endl;
}
}
//end of the codes
//from here: std::cin>>i;
(gdb) s //here ,no chance to input anything.
(gdb) s
(gdb) s
not digit ,once more
(gdb) s
i=4
(gdb) s
(gdb) s
bad boy
(gdb) s //no chance to input anything,there is no prompt for input.
(gdb) s
(gdb) s
not digit ,once more
(gdb) s
i=4
(gdb)
But I can input something when I am no in the main function.
anyhelp?
thanks very much.