473,383 Members | 1,896 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,383 software developers and data experts.

Error in 'while' loop MS VS8

i want to know why my compiler microsot visual studio 8 refuse this wile loop in the runing mood and begin to debug
Expand|Select|Wrap|Line Numbers
  1. char a [] = "(12+12)"  ;  //for example
  2. int i=0;
  3. while ( a[i] ! = '+'  ||  a[i] ! =  '-' || a[i] ! = '*' ) 
  4. {
  5. ++i;
  6. cout<<a[i];
  7.  
if this is wrong way to wirte it this way , what's the wright one
Sep 2 '07 #1
2 1126
JosAH
11,448 Expert 8TB
i want to know why my compiler microsot visual studio 8 refuse this wile loop in the runing mood and begin to debug
char a [] = "(12+12)" ; //for example
int i=0;
while ( a[i] ! = '+' || a[i] ! = '-' || a[i] ! = '*' )
{
++i;
cout<<a[i];
)

if this is wrong way to wirte it this way , what's the wright one
Your while clause (condition) is incorrect. Suppose a[i] == '+', most certainly
it isn't equal to '-' and your while clause is true again.

Better change those || to &&

kind regards,

Jos
Sep 2 '07 #2
i want to know why my compiler microsot visual studio 8 refuse this wile loop in the runing mood and begin to debug
char a [] = "(12+12)" ; //for example
int i=0;
while ( a[i] ! = '+' || a[i] ! = '-' || a[i] ! = '*' )
{
++i;
cout<<a[i];
)

if this is wrong way to wirte it this way , what's the wright one
Your condition in while loops will always remain true in this case so the loop will not terminate, so MS VS starts to debug when array index 'i' crosses array length and you try to cout unauthorized memory area. In this case it will give you Access Violation Error message if you try to run the executable directly by clicking on it.
Sep 2 '07 #3

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

Similar topics

5
by: NanQuan | last post by:
I'm hoping someone can help me solve this error since I am at a total loss here. Usually I don't bother posting on any forums or groups on the internet and prefer to solve stuff myself but this is...
10
by: ale.of.ginger | last post by:
Greetings! I am trying to make a multiplayer (no AI, 2 person) game of tic tac toe in Python. So far it has been pretty simple. My only concern is with the win checking to see if a person has...
5
by: hpy_awad | last post by:
I wrote that example from a book and there is en error in the display module that it does not showing all the records are entered in the input module. I traced with some printf statments without...
7
by: scorpion53061 | last post by:
This exception occured while running in the development environment. The debugger didnt catch it though it appeared as a message box prompt........does anyone have insight on this? ...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
1
by: Eric | last post by:
When I run my script it gives error on the following line: strEmail = Right(strEmail, (Len(strEmail) - 1)) I enclose my code and the sample text file too Thanks,...
13
by: Bill | last post by:
Can someone help me with this error: error C2143: syntax error : missing ';' before 'type' Here is the line it's complaining about: for(int i=0;i<4;i++){ printf("%d",x); }
4
by: Hypnotik | last post by:
Hello everyone. I'm working on a program that crashes whenever I enter the value that is supposed to stop the program. The program takes in various pieces of info, has a struct and a class. The...
15
by: Lawrence Krubner | last post by:
Does anything about this script look expensive, in terms of resources or execution time? This script dies after processing about 20 or 25 numbers, yet it leaves no errors in the error logs. This is...
7
vikas251074
by: vikas251074 | last post by:
I am getting error above in following code since few days giving tension day and night. How can I solve this? I am facing since Oct.25. in line no. 362 After doing a lot of homework, I am...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.