delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/03/03/05:33:07

From: Martin Laws <martin DOT laws AT bt DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Newbie question - using || operator
Date: Wed, 03 Mar 1999 10:21:55 +0000
Organization: BT Labs, Martlesham Heath, Ipswich, UK
Lines: 42
Message-ID: <36DD0D43.7911201B@bt.com>
NNTP-Posting-Host: pc68bf.btlabs.bt.co.uk
Mime-Version: 1.0
X-Mailer: Mozilla 4.5 [en] (Win95; I)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Has anyone had problems compiling simple programs which use the logical
OR
('||') operator?

The sample program I am trying to compile is the following:

#include <iostream.h>
int main()
{
 enum Days { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday,
Saturday };

 Days DayOff;
 int x;

 cout << "What day do you want off (0-6): ";
 cin >> x;
 DayOff = Days(x);

 if (DayOff == Sunday || DayOff == Saturday)
   cout << "\n You're already off at weekends!\n";
 else
   cout << "\n Okay , It's now in the diary\n";
 return 0;
}

When I try to compile it, gcc comes up with a parse error on the "if"
statement line
"parse error before character 0335".
The program was entered using RHIDE and I have checked to see if the
"||" characters look OK by using DOS EDIT (they seem to look OK ).
These compile errors occur both using the Run command in RHIDE or
compiling using "gxx -o prog.exe prog.cpp" from a DOS command prompt.

Any ideas anyone? I am new to C/C++ and so am trying to work through
some simple tutorials.

Any help would be appreciated.

Martin


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019