473,509 Members | 2,528 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with Loop until "X" please

49 New Member
Hi, I feel foolish - I am trying to do a very simple thing... I have a loop to gather input from a user and I want it to allow seamless entry until the user enters an X then I want it to spit out a small method that tallys the info up.

so here's my snippit:

Expand|Select|Wrap|Line Numbers
  1. while(dat != "x" || dat != "X")
  2.  
  3. {
  4.  cout << "" << endl;
  5.  cin >> dat;
  6.  num=stod(dat);
  7.  stat1.next(num);
  8. }
  9.  
  10. stat1.screenPrint();
  11.  
  12.  
  13.  
it steps thru the loop just fine till I hit X then it craps out on me and I get a Debug Error.

Debug Error!
program:...al studio 2012\Projects\Statistician2\Debug\Statistician2.ex e
R6010
-abort() has been called
(Press Retry to debug the application)

If I hit ignore it just quits

it never exits the loop properly... what am I missing?
Sep 8 '14 #1
3 1255
mukherjee
9 New Member
You may use Vector to store the inputs.
Sep 9 '14 #2
weaknessforcats
9,208 Recognized Expert Moderator Expert
You are using an OR. So if you enter x, it's not an X and you stay in the loop. If you enter X, it's not an x and you stay in the loop.

Use the AND:

Try:

Expand|Select|Wrap|Line Numbers
  1. while(dat != "x" && dat != "X")
  2.  
  3. {
  4. etc...
Now you stay in the loop if the dat is not x AND not X.

Also "x" and "X" are strings whereas 'x' and 'X' are chars. Ther may be an issue here but I don't the see definition of dat so I don't know.
Sep 9 '14 #3
donbock
2,426 Recognized Expert Top Contributor
stod on line 6 throws an invalid-argument exception when you enter "X" because that is not a valid number. Notice that "X" and "x" are not the only possible invalid arguments to stod.

What does it mean to "hit ignore"?
Sep 9 '14 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2054
by: Mike | last post by:
Hi All, I have been struggling with this for weeks now and I just can't get my head around it. I am trying to convert this procedure to VB.NET. In particular I am having problems with the...
36
42352
by: Remi Villatel | last post by:
Hi there, There is always a "nice" way to do things in Python but this time I can't find one. What I'm trying to achieve is a conditionnal loop of which the condition test would be done at...
1
2615
by: Randy | last post by:
Access= 2002 I'm NOT a Programmer, but I have used VB in the past to do some things ( Spaghetti Code King) so I have some understanding of Coding I need to replace a text field (teacher) in...
3
1630
by: Julia | last post by:
I need help with architecture design,please: I have a server which constantly downloading messages from the internet and store them inside a data base. the server have two administrators...
6
14383
by: placid | last post by:
Hi all, Im using the cmd module and i have command that loops and keeps on printing text, what i want to be able to do is loop until the user presses a particular key, say Q/q ? I tried the...
1
1106
by: adamchiaz | last post by:
I am trying to access progressive.com and it says that javascript is disabled and i went thru everything and all the settings are correct..it is enabled and is still not recognizing...can anybody...
2
1461
by: shogot99 | last post by:
Till here the info gotten is ok Loop Until strainfo = "" ScreenMNS.WaitHostQuiet (400) Second process Copy "B" & paste in "E" Range("B2:B600").Select
1
963
by: redAllison21 | last post by:
Dim fileToCopy, NewCopy, txtFiles, inpFiles As String Dim sr As New StringReader(TextBox3.Text) fileToCopy = ("c:\" + inpFiles + ".txt") NewCopy = ("C:\jj.txt") ...
1
1345
by: Scott Dreadlock | last post by:
Hi, I'm creating a Tarot card randomizer in VB.net just for an excersize of trying to remain faithful to random while still using certain rules - like no duplicate values. Here's the code. I've...
0
7135
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...
0
7410
jinu1996
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...
0
7505
tracyyun
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...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4729
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...
0
3215
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...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
440
bsmnconsultancy
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...

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.