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

no else for corresponding if

for some reason i thought i could have more if statements than else
statements.

if (!inputFile)
{
cerr<<"file not found";
}

if (something)
{
do operation;
}

else
{
do somethingElse;
}

in g++, i get an error message saying "parse error before else" which
translated to visual c++ means not same amout of elses as if's. i didnt know
that was illegal. was i wrong?
Jul 19 '05 #1
2 1753
never mind.......closing bracket was { instead of } ........stupid
me.
Jul 19 '05 #2
In article <yC*********************@twister.southeast.rr.com> ,
pentiumPunk <Br***@triad.rr.com> wrote:
for some reason i thought i could have more if statements than else
statements.

if (!inputFile)
{
cerr<<"file not found";
}

if (something)
{
do operation;
}

else
{
do somethingElse;
}

in g++, i get an error message saying "parse error before else" which
translated to visual c++ means not same amout of elses as if's. i didnt know
that was illegal. was i wrong?


The sort of thing you have above *should* compile as two separate
if-statements, the first one without an else-clause. But that's not
compilable code anyway. Post a short complete example program that
compiles cleanly *except* for the error message that you describe above.

--
Jon Bell <jt*******@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
Jul 19 '05 #3

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

Similar topics

11
by: dmbkiwi | last post by:
I am new to this group, and relatively new to python programming, however, have encountered a problem I just cannot solve through reading the documentation, and searching this group on google. I...
6
by: Bart Nessux | last post by:
Should an if statement have a corresponding else statement? Or, is it OK to have an if statement by itself. For completeness, it seems the two should be together, but from experience I know that a...
5
by: Raphael Gluck | last post by:
Hi I'm fairly new to coding in asp and i'm trying to create a simple if.. else... condition It's for asp web page, and is linked to my database, but i figured since it's a basic question, it...
18
by: swaroophr | last post by:
Which of switch statement and if-else statement takes less time to execute?
4
by: Jim in Arizona | last post by:
This doesn't make any sense to me. I'm hoping some SQL guru out there knows the answer. I'm making a help desk type database system. There's only two tables, one called TTickets and the other...
10
by: JohnR | last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a datagridtablestyle defined. I use the datagridtablestyle to change the order of the columns (so they can be different than...
24
by: Kunal | last post by:
Hello, I need help in removing if ..else conditions inside for loops. I have used the following method but I am not sure whether it has actually helped. Below is an example to illustrate what I...
1
by: roveagh1 | last post by:
Hi I've been using the 2 year old link below to repeat values from previous record field into current corresponding field. It's worked fine for text but the last piece of advice was to use the same...
23
by: bearophileHUGS | last post by:
So far in Python I've almost hated the 'else' of the 'for' loops: - I have problems to remember its meaning; - It gives me little problems when I later want to translate Python code to other...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.