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<iostrea m>
#include<cstdli b>
using std::isdigit;
int main()
{ int i=4;
try
{
while(1)
{
std::cin>>i;
if(!isdigit(i))
{
std::cout<<"not digit ,once more"<<std::end l;
std::cout<<"i=" <<i<<std::end l;
}
if(i==2)
{
std::cout<<"goo d boy"<<std::endl ;
}
else
{
std::cout<<"bad boy"<<std::endl ;
}
}
}
catch(...)
{
std::cout<<"exe cption 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. 6 1549
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
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?
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.
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.
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.
"davinci" <fl*********@16 3.com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 runs for hours it would be nice to see the
output as it is written. I know that I can switch to a
python interpreter window and paste the code in etc but I don't
care about the interpreter, just about the (printed) output
after C-c C-c.
|
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 of the class – the
numerator and the denominator. Provide a constructor that enables an
object of this class to be initialized when it is declared. The
constructor should contain default values in case no initializers are
provided and should...
|
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. When it completes, it can call a success, or a failure
function. The names of these success, or failure functions will differ,
and I'd like to know how I can pass the name of a function to my tool,
and how my tool can call the function, using that...
|
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 database for
an attorney's office. I'm sure it must be do-able. I know
better than to mention the term "S__dK__ys" in conjunction
with this topic. I've read enough in here to know that is
extremely unreliable. Am sorry even that I have to use
IE...
|
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 get it to upload a file to the FTP server. I just get a
"Cannot connect to remote server" error after this TRY:
s = New Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp)
| |
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 the html page
controls the form fields that are required. It doesn't function like
it's supposed to and I can leave all the fields blank and it still
submits the form. Also I can't get it to transfer the file in the
upload section. The file name...
|
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: 'ascii' codec can't decode byte 0xXX in position
0: ordinal not in range(128)
I spent two hours fixing it, and I hope it's done. The solution is one
|
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 great. I know its sorta long, but maybe you only have to few the first few paragraphs.
Problem:
Write a program in C that generates number palindromes using the algorithm below (see 3. on the next page) and allows the user to try this...
|
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 producer-consumer problem. There will be one producer thread and multiple consumer threads. The items in the buffer will be inter values. The producer thread will produce (get) the buffer items by reading integers from standard input (stdin) and...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |