473,473 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

parse error before '=' token

#include <stdio.h>
#define BALANCE 5000

int main(){
int balance = BALANCE;

return 0;
}

when i compile it, an error occurs,what's happen?
ass3ext.c:9: error: parse error before '=' token

thanks!
Nov 15 '05 #1
22 5113

"nick" <i1********@yahoo.com> wrote in message
news:di***********@justice.itsc.cuhk.edu.hk...
#include <stdio.h>
#define BALANCE 5000

int main(){
int balance = BALANCE;

return 0;
}

when i compile it, an error occurs,what's happen?
ass3ext.c:9: error: parse error before '=' token


Post the real code giving the error.
What you've posted should compile just fine.

-Mike
Nov 15 '05 #2

nick wrote:
#include <stdio.h>
#define BALANCE 5000

int main(){
int balance = BALANCE;

return 0;
}

when i compile it, an error occurs,what's happen?
ass3ext.c:9: error: parse error before '=' token

thanks!


This code compiles properly on gcc 3.4.2. Please verify once again and
let us know what is the exact error.

Nov 15 '05 #3
#include <stdio.h>
#define BALANCE 5000

int main()
{
int balnace = BALNACE;

return 0;
}

the code have not any problem

Nov 15 '05 #4
"littleroy" <li***********@gmail.com> writes:
#include <stdio.h>
#define BALANCE 5000

int main()
{
int balnace = BALNACE;

return 0;
}

the code have not any problem


What?

Please learn to post properly; instructions have been posted repeatedly.

You re-posted *nearly* the same code from the original post, except
that the original code compiles (as numerous people have already
said), and yours doesn't (you introduced typos because you didn't post
the same code you compiled).

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #5
nick wrote:

#include <stdio.h>
#define BALANCE 5000

int main(){
int balance = BALANCE;

return 0;
}

when i compile it, an error occurs,what's happen?
ass3ext.c:9: error: parse error before '=' token


The sample code you posted is only 8 lines long, and the "=" is on
line 5, which make the error on line 9 hard to diagnose.

Please post a complete example of code which gives the error.

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Nov 15 '05 #6
nick <i1********@yahoo.com> wrote in news:dikd0q$2aoq$1
@justice.itsc.cuhk.edu.hk:

#include <stdio.h>
#define BALANCE 5000

int main(){
int balance = BALANCE;

return 0;
}

when i compile it, an error occurs,what's happen?
ass3ext.c:9: error: parse error before '=' token

thanks!


Some compilers get all pissy over stray nonprinting characters, causing
them to spew errors with no obvious cause.

(Did you copy the file from a Windows machine to a Unix box, by any chance?
I once used a compiler that gagged on the ^M that Windows puts at the end
of every line.)
Nov 15 '05 #7

"littleroy" <li***********@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
#include <stdio.h>
#define BALANCE 5000

int main()
{
int balnace = BALNACE;

return 0;
}

the code have not any problem


Nick's code is fine, no problem.

Your code, however, does have a problem.

-Mike
Nov 15 '05 #8

"Dale" <da***@gas.orange> wrote in message
news:Xn*************************@204.153.244.156.. .
nick <i1********@yahoo.com> wrote in news:dikd0q$2aoq$1
@justice.itsc.cuhk.edu.hk:

#include <stdio.h>
#define BALANCE 5000

int main(){
int balance = BALANCE;

return 0;
}

when i compile it, an error occurs,what's happen?
ass3ext.c:9: error: parse error before '=' token

thanks!


Some compilers get all pissy over stray nonprinting characters, causing
them to spew errors with no obvious cause.

(Did you copy the file from a Windows machine to a Unix box, by any
chance?
I once used a compiler that gagged on the ^M that Windows puts at the end
of every line.)


In Windows, '^M' is the (console's) glyph for the ASCII
character with value 13, the 'newline' character. If you
have a C compiler that can't handle newline characters
in a source file, dump it, fast.

-Mike
Nov 15 '05 #9
"Mike Wahler" <mk******@mkwahler.net> writes:
"Dale" <da***@gas.orange> wrote in message
news:Xn*************************@204.153.244.156.. .
nick <i1********@yahoo.com> wrote in news:dikd0q$2aoq$1
@justice.itsc.cuhk.edu.hk: [...] (Did you copy the file from a Windows machine to a Unix box, by any
chance?
I once used a compiler that gagged on the ^M that Windows puts at the end
of every line.)


In Windows, '^M' is the (console's) glyph for the ASCII
character with value 13, the 'newline' character. If you
have a C compiler that can't handle newline characters
in a source file, dump it, fast.


Not quite. (The following is partially off-topic, but it's relevant
to the handling of text files and of C source files.)

In Windows text files, the end-of-line marker is a CR followed by an
LF (ASCII codes 10 and 13, respectively). If you read a Windows text
file in binary mode, you'll see the "\r\n" characters. If you read it
in text mode, the end-of-line marker will be translated to a single
"\n" character; C calls this a "newline" character, ASCII calls it
"LF" or line-feed.

Unix text files use a single LF character to mark the end of a line;
no translation is necessary when reading a file in either text or
binary mode.

(Note that a C compiler needn't be implemented in C, and needn't
necessarily follow the rules of C text files when reading source
files.)

If you copy a Windows text file to a Unix system without translating
the end-of-line markers, the result will be an invalid text file with
an extraneous '\r' character (also represented as "^M") at the end of
each line. Though a Unix compiler can legally ignore extraneous '\r'
characters, I don't believe it's required to.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #10
Dale <da***@gas.orange> writes:
nick <i1********@yahoo.com> wrote in news:dikd0q$2aoq$1
@justice.itsc.cuhk.edu.hk:

#include <stdio.h>
#define BALANCE 5000

int main(){
int balance = BALANCE;

return 0;
}

when i compile it, an error occurs,what's happen?
ass3ext.c:9: error: parse error before '=' token

thanks!


Some compilers get all pissy over stray nonprinting characters, causing
them to spew errors with no obvious cause.

(Did you copy the file from a Windows machine to a Unix box, by any chance?
I once used a compiler that gagged on the ^M that Windows puts at the end
of every line.)


Since the compiler is flagging an error before the '=' token, it's
unlikely that it's a problem with end-of-line markers.

But since the OP still hasn't shown us the actual code that causes the
error (or his compiler is broken in an unlikely fashion, or he's
invoking it with "-Dbalance=="), there's not much further point in
guessing.

This happens a lot around here. Somebody asks a question, half a
dozen people ask for more information, and we never hear from the
original poster again.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #11
nick <i1********@yahoo.com> writes:
#include <stdio.h>
#define BALANCE 5000

int main(){
int balance = BALANCE;

return 0;
}

ass3ext.c:9: error: parse error before '=' token


Did you accidentally put an `=' in the macro definition? We see
that around here from time to time.
--
"Your correction is 100% correct and 0% helpful. Well done!"
--Richard Heathfield
Nov 15 '05 #12
Keith Thompson wrote:
"Mike Wahler" <mk******@mkwahler.net> writes:
"Dale" <da***@gas.orange> wrote in message
news:Xn*************************@204.153.244.156 ...
nick <i1********@yahoo.com> wrote in news:dikd0q$2aoq$1
@justice.itsc.cuhk.edu.hk:
[...]
(Did you copy the file from a Windows machine to a Unix box, by any
chance?
I once used a compiler that gagged on the ^M that Windows puts at the end
of every line.)


In Windows, '^M' is the (console's) glyph for the ASCII
character with value 13, the 'newline' character. If you
have a C compiler that can't handle newline characters
in a source file, dump it, fast.

Not quite. (The following is partially off-topic, but it's relevant
to the handling of text files and of C source files.)

In Windows text files, the end-of-line marker is a CR followed by an
LF (ASCII codes 10 and 13, respectively). If you read a Windows text
file in binary mode, you'll see the "\r\n" characters. If you read it
in text mode, the end-of-line marker will be translated to a single
"\n" character; C calls this a "newline" character, ASCII calls it
"LF" or line-feed.

Unix text files use a single LF character to mark the end of a line;
no translation is necessary when reading a file in either text or
binary mode.

(Note that a C compiler needn't be implemented in C, and needn't
necessarily follow the rules of C text files when reading source
files.)

If you copy a Windows text file to a Unix system without translating
the end-of-line markers, the result will be an invalid text file with
an extraneous '\r' character (also represented as "^M") at the end of
each line. Though a Unix compiler can legally ignore extraneous '\r'
characters, I don't believe it's required to.


Just a nit. The CPM/DOS/Windows text file line ending is CR, LF or 0D,
0A or 13, 10. Also there is the EOF character '^Z' or 1A or 26 to tell
us the previous character was the last one. This last because CPM's
directory structure maintained file sizes in 128-byte records, not
bytes. No big deal for binary stuff but if you want to concatenate two
text files, you really need to know where the first one ends.

Our C implementations on DOS/Windows pretend they are running on Unix so
that 'text' mode files that might have been written by DOS will be
'treated' such that 0D character is ignored and 1A will be treated as
EOF. The C program sees lines ending with 0A ('\n') only. We never see
the 0D or 1A characters.

Orthogonally, our C implementation when writing text lines will enhance
the "\n" to "\r\n" to make DOS/Windows happy. At least one C
implementation (from Software Toolworks for CPM circa 1980} will append
the 1A character on closing the text file.

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 15 '05 #13
In article <rb********************@comcast.com>,
Joe Wright <jw*****@comcast.net> wrote:

Just a nit. The CPM/DOS/Windows text file line ending is CR, LF or 0D,
0A or 13, 10. Also there is the EOF character '^Z' or 1A or 26 to tell
us the previous character was the last one. This last because CPM's
directory structure maintained file sizes in 128-byte records, not
bytes. No big deal for binary stuff but if you want to concatenate two
text files, you really need to know where the first one ends.

Our C implementations on DOS/Windows pretend they are running on Unix so
that 'text' mode files that might have been written by DOS will be
'treated' such that 0D character is ignored and 1A will be treated as
EOF. The C program sees lines ending with 0A ('\n') only. We never see
the 0D or 1A characters.

Orthogonally, our C implementation when writing text lines will enhance
the "\n" to "\r\n" to make DOS/Windows happy. At least one C
implementation (from Software Toolworks for CPM circa 1980} will append
the 1A character on closing the text file.


For the portability-crazed, macintosh text files are just CR
between lines (0x0D, or 13).

Also, it's possible to autodetect this to some degree. Read in
the first 1024 bytes or so (in binary mode) and scan for control
characters.

some CR's but no LF's -> Mac
some LF's but no CR's -> Unix
same number (+/- 1) of CR's and LF's -> DOS
lots of null chars, control chars, or high bit set chars -> binary data
no control chars at all, just plain chars -> one line w/o a EOL indicator
lots of trailing space every 80 chars -> uh oh

Last time I dealt with this issue, I read the file byte by byte
in binary mode and cut the lines at CR's and LF's, but only made
one cut if the LF was immediately after a CR. This had the, uh,
feature that a concatenation of files from different machines
with different linefeed conventions would still work.

Now I have left a nit for someone else to pick...
Nov 15 '05 #14
Joe Wright wrote:
Just a nit. The CPM/DOS/Windows text file line ending is CR, LF or 0D,
0A or 13, 10.


Those of us programming on PDP-1,5,6,7,8,10,11,12,15,20 etc. machines
long before "CPM/DOS/Windows" know that a CRLF is 15,12.
Nov 15 '05 #15
In article <GcW3f.2483$i%.2376@fed1read07>,
Anonymous 7843 <an******@example.com> wrote:
For the portability-crazed, macintosh text files are just CR
between lines (0x0D, or 13).


Used to be. Macs are now unix.

-- Richard
Nov 15 '05 #16
In article <di**********@pc-news.cogsci.ed.ac.uk>,
Richard Tobin <ri*****@cogsci.ed.ac.uk> wrote:

In article <GcW3f.2483$i%.2376@fed1read07>,
Anonymous 7843 <an******@example.com> wrote:
For the portability-crazed, macintosh text files are just CR
between lines (0x0D, or 13).


Used to be. Macs are now unix.


Oh well, it's not like Teach Text was my editor of choice. :-)
Nov 15 '05 #17
In article <GcW3f.2483$i%.2376@fed1read07>,
Anonymous 7843 <an******@example.com> wrote:
Also, it's possible to autodetect this to some degree. Read in
the first 1024 bytes or so (in binary mode) and scan for control
characters. lots of null chars, control chars, or high bit set chars -> binary data


Or UTF-8 -- for text that would fall into the normal ASCII range,
the first of every pair of characters is NUL.
--
"No one has the right to destroy another person's belief by
demanding empirical evidence." -- Ann Landers
Nov 15 '05 #18
In article <di**********@canopus.cc.umanitoba.ca>,
Walter Roberson <ro******@ibd.nrc-cnrc.gc.ca> wrote:
lots of null chars, control chars, or high bit set chars -> binary data
Or UTF-8 -- for text that would fall into the normal ASCII range,
the first of every pair of characters is NUL.


That would be UTF-16 (and "first" would only be true for big-endian
UTF-16). UTF-8 is a variable-length encoding and is quite reliably
detectable because of strong constraints on sequences of bytes above
127.

-- Richard
Nov 15 '05 #19
Keith Thompson wrote:
"Mike Wahler" <mk******@mkwahler.net> writes:
"Dale" <da***@gas.orange> wrote in message
news:Xn*************************@204.153.244.156.. .
nick <i1********@yahoo.com> wrote in news:dikd0q$2aoq$1
@justice.itsc.cuhk.edu.hk: [...] (Did you copy the file from a Windows machine to a Unix box, by any
chance?
I once used a compiler that gagged on the ^M that Windows puts at the end
of every line.)


In Windows, '^M' is the (console's) glyph for the ASCII
character with value 13, the 'newline' character. If you
have a C compiler that can't handle newline characters
in a source file, dump it, fast.


Not quite. (The following is partially off-topic, but it's relevant
to the handling of text files and of C source files.)

In Windows text files, the end-of-line marker is a CR followed by an
LF (ASCII codes 10 and 13, respectively). If you read a Windows text
file in binary mode, you'll see the "\r\n" characters. If you read it
in text mode, the end-of-line marker will be translated to a single
"\n" character; C calls this a "newline" character, ASCII calls it
"LF" or line-feed.

Unix text files use a single LF character to mark the end of a line;
no translation is necessary when reading a file in either text or
binary mode.

(Note that a C compiler needn't be implemented in C, and needn't
necessarily follow the rules of C text files when reading source
files.)

If you copy a Windows text file to a Unix system without translating
the end-of-line markers, the result will be an invalid text file with
an extraneous '\r' character (also represented as "^M") at the end of
each line. Though a Unix compiler can legally ignore extraneous '\r'
characters, I don't believe it's required to.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.


Hi
Linux offers two utlities : unix2dos & dos2unix
Hope that's of some use.
Regards,
Frodo Baggins

Nov 15 '05 #20
Martin Ambuhl wrote:
Joe Wright wrote:
Just a nit. The CPM/DOS/Windows text file line ending is CR, LF
or 0D, 0A or 13, 10.


Those of us programming on PDP-1,5,6,7,8,10,11,12,15,20 etc. machines
long before "CPM/DOS/Windows" know that a CRLF is 15,12.


Are you speaking in octal? Or is that just a coincidence?

Nov 15 '05 #21
"Old Wolf" <ol*****@inspire.net.nz> writes:
Martin Ambuhl wrote:
Joe Wright wrote:
Just a nit. The CPM/DOS/Windows text file line ending is CR, LF
or 0D, 0A or 13, 10.


Those of us programming on PDP-1,5,6,7,8,10,11,12,15,20 etc. machines
long before "CPM/DOS/Windows" know that a CRLF is 15,12.


Are you speaking in octal? Or is that just a coincidence?


Assembly language on the PDP-11 used octal extensively, mostly because
most of the instruction fields (specifying registers, addressing
modes, etc.) were 3 bits wide. I'm guessing the same was true on the
other machines in the PDP-* series.

(I'm using past tense because these machines are no longer in wide
use, though I suppose some of them are still operational.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #22
On Mon, 17 Oct 2005 22:14:30 GMT, Keith Thompson <ks***@mib.org>
wrote:
"Old Wolf" <ol*****@inspire.net.nz> writes:
Martin Ambuhl wrote:
Joe Wright wrote:

Just a nit. The CPM/DOS/Windows text file line ending is CR, LF
or 0D, 0A or 13, 10.

Those of us programming on PDP-1,5,6,7,8,10,11,12,15,20 etc. machines
long before "CPM/DOS/Windows" know that a CRLF is 15,12.
Are you speaking in octal? Or is that just a coincidence?


Assembly language on the PDP-11 used octal extensively, mostly because
most of the instruction fields (specifying registers, addressing
modes, etc.) were 3 bits wide. I'm guessing the same was true on the
other machines in the PDP-* series.

More or less. AFAIK no DEC machines except PDP-11 and VAX have
(explicitly coded, mostly orthogonal) modes.

(5 and) 8, and I believe 12 and 15, have 3-bit opcode, and for I/O
6-bit address and 3-bit function(s), but 7-bit local address and no
numbered registers. It also conventionally puts 2 x 6-bit characters
(ASCII 040-137 or special + 040-136) in 12-bit word.

(6 and) 10 have 9-bit opcode, but 4-bit GPR, but extensively uses 2 x
18-bit halfword which breaks nicely in octal, and sometimes uses 6 x
6-bit characters, but also much 5 x 7-bit + 1. There is no PDP-20;
DECsystem-10 and DECsystem-20 are different packagings of PDP-10.

7 (and 9) have 18-bit word, and (usually?) stores characters in either
6-bit bytes or 9-bit halfwords. I don't remember instruction formats.

PDP-1 I never actually saw.

Some DECphiles (or maniacs?) who treasured their feeling of isolation
from and arguably superiority over IBM S/360 felt horribly betrayed
when VAX went almost-fully-byte and hex. At least not bigendian. :-)
(I'm using past tense because these machines are no longer in wide
use, though I suppose some of them are still operational.)


The folks on comp.sys.pdp10 are proud that there are still a handful
of (competitive) clones in real use -- to the absolute purist these
aren't _true_ PDP-10's but to a program, and programmer, they are.
<ObC> The company even funded a gcc port about 2 years back. </>
In addition there seem to be several hobbyist restorations and at
least one museum. As well as several(!) simulators for everyone else.

comp.sys.pdp{11,8} have several active hobbyists and hints of more,
and every few months or so reports of machines or at least parts
becoming available because they are being retired from service,
generally in niche applications that apparently have been undisturbed
-- according to reports in some cases not even cleaned -- for years.

I don't try to follow the VAX and Alpha groups but I expect there are
still noticeable numbers of them. But aren't in the PP list.

- David.Thompson1 at worldnet.att.net
Nov 15 '05 #23

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

Similar topics

22
by: Ram Laxman | last post by:
Hi all, I have a text file which have data in CSV format. "empno","phonenumber","wardnumber" 12345,2234353,1000202 12326,2243653,1000098 Iam a beginner of C/C++ programming. I don't know how to...
4
by: learning_C++ | last post by:
Hi, I try to use input = new istrstream(argv,strlen(argv)); in my code, but it always says error: " error: parse error before `(' token" please help me! Thanks, #include <map>
19
by: Johnny Google | last post by:
Here is an example of the type of data from a file I will have: Apple,4322,3435,4653,6543,4652 Banana,6934,5423,6753,6531 Carrot,3454,4534,3434,1111,9120,5453 Cheese,4411,5522,6622,6641 The...
21
by: William Stacey [MVP] | last post by:
Anyone know of some library that will parse files like following: options { directory "/etc"; allow-query { any; }; // This is the default recursion no; listen-on { 192.168.0.225;...
21
by: BWIGLEY | last post by:
Basically I've just started making a game. So far it makes an array 25 by 20 and tries to make five rooms within it. In scr_make_room() there's parse errors: 20 C:\c\Rooms\Untitled1.c parse error...
6
by: Richard | last post by:
Which way would you guys recommened to best parse a multiline file which contains two fields seperated by a tab. In this case its the linux/proc/filesystems file a sample of which I have included...
4
by: ohaqqi | last post by:
Hi everybody. I haven't programmed anything in about 8 years, I've read up a little bit on C and need to write a shell in C. I want to use strtok() to take an input from a user and parse it into the...
1
by: lucasstark | last post by:
I have the following XML File: I want to parse the file so that I can add each node to a database: So I need to parse the bottom node and say: admissions, application. Then go up a level and...
0
by: Anish Chapagain | last post by:
Hi, i tried to compile the swig .i file but am having probel with the error: parse error before % token example.i 1. %module example 2. %{ 3. #include <header.h> 4. %}
0
marktang
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,...
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
agi2029
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,...
0
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...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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.