473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

xemacs,gdb,I can't input from the terminal in main function,but others functions well.


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.

Sep 8 '05 #1
6 1524
CK
Not sure If I understand the issue correctly. Even I am not able to
compile your code, it gives me syntax error.

If I change the line using std::isdigit;
to
using namespace std;

then only I can compile the code and run it.

So let me know what is the issue you are having now.

CK

Sep 8 '05 #2
Thanks.
It is ok now.
but ,it is so inscrutability.
I had remember that there is no the function isdigit() ,and there is no
'using std::isdigit' I can't input anything in main function.

I didn't know why.
and if I declare using namespace std before main function and then
didn't use
,such as std::cout,
then error is:cout is not have been declared.
why?

Sep 8 '05 #3
Now ,I can't again.I can't input anything.
it is so interesting .
Is it a bug of gdb?
But I think input a integer is a common operation.

Sep 8 '05 #4
Now ,I can't again.I can't input anything.
it is so interesting .
Is it a bug of gdb?
But I think input a integer is a common operation,so I can't belive it
is the problem of compiler.

Sep 8 '05 #5
I am sorry to touble you.
I get the answer now .
if I enter interger all is ok.
once I enter a non-integer characater,then I can't input anymore.

Sep 8 '05 #6

"davinci" <fl*********@163.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
I am sorry to touble you.
I get the answer now .
if I enter interger all is ok.
once I enter a non-integer characater,then I can't input anymore.


One way to avoid that problem is to input into a char (or char array, or
std::string). Then you can check if the character is in the range '0'
through '9', (and only then convert it to an integer if that's what you
need).

-Howard
Sep 8 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jay Davis | last post by:
What is the best way to run python in Xemacs (with C-c C-c) with real time standard output? Right now, the python output window fills up when the program is finished running, but if the program...
5
by: surrealtrauma | last post by:
the requirement is : Create a class called Rational (rational.h) for performing arithmetic with fractions. Write a program to test your class. Use Integer variables to represent the private data...
39
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
21
by: MLH | last post by:
A97 procedure to open http://www.arch.com/message/ enter an 800 number, press "Continue", enter a text msg string from a memo field and press "Send" This is a calendaring and appointment A97...
18
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
4
by: Oleg Parashchenko | last post by:
Hello, I'm working on an unicode-aware application. I like to use "print" to debug programs, but in this case it was nightmare. The most popular result of "print" was: UnicodeDecodeError:...
1
by: td0g03 | last post by:
Hello, I am new to C and I am new to English. I not sure what palindromes mean. I don't know exactly what my teacher wants me to do. If someone could explain it to me in a different way that would be...
1
by: hboosh | last post by:
hi all i want a help about my project this is the discribtion: Description This assignment is to be done individually. You are to implement a multi-threaded solution for the bounded buffer...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.