• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# Parse?

## Recommended Posts

whenever i try to compile my program, i get a parse error. What is it and how can i fix it?

##### Share on other sites
quote:
Original post by dchar3
whenever i try to compile my program, i get a parse error. What is it and how can i fix it?

How are we supposed to know if you don''t give us any details? Post the code causing the error, tell us what language it is, what compiler you are using, and what the error message is (and which line it refers to).

##### Share on other sites
What that means is you ahve some kind of _syntax_ error- that is, your program is missing something that should be there, or it has something that should NOT be there.

##### Share on other sites
[Removed. Please go to the General Programming forum for that, it is inappropriate to post it here]

[edited by - michalson on May 28, 2003 12:37:32 PM]

##### Share on other sites
Quite a common and easy parse error to make is leaving out a closing function brace. For example:

int main(){    ...    return 0;  <-- no curly brace '}'

But, as SabreMan basically said, we can only make guesses if you don't provide source code, which wastes not only our time, but yours too.

[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]

[edited by - Lektrix on May 28, 2003 12:44:32 PM]

##### Share on other sites
here it is, due to popular demand, the source code for Dev C++ 4 compiler! but i dont think its exactly right.remember im a beginner so im just trying things to see how they work.

int main()
{
cout << "I cant remember this part";
}

##### Share on other sites
quote:
Original post by dchar3
here it is, due to popular demand, the source code for Dev C++ 4 compiler! but i dont think its exactly right.remember im a beginner so im just trying things to see how they work.

int main()
{
cout << "I cant remember this part";
}

first off, that''s not a parse error.. int main() must return a value.
also- there are no other "parse" errors in that code.
if you dont post the code verbatem, then you''re pissing in the metaphorical wind.

-eldee
;another space monkey;
[ Forced Evolution Studios ]

Do NOT let Dr. Mario touch your genitals. He is not a real doctor!

##### Share on other sites
That should work, so long as you have the two lines:
#include <iostream>using namespace std;
at the top of your file. Incidently, you should return an integer from main(), but it will still work as the standard says to implicitly return 0.

#include <iostream>#include <cstdlib>int main(){    std::cout << "I am testing my compiler!\n\n";    system("PAUSE");    return 0;}
Also, it seems that that is a rather old version of Dev-C++ (unless you have made a typo) you might want to download the latest.

Edit: Damn you, fast people!

[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]

[edited by - Lektrix on May 28, 2003 1:04:08 PM]

##### Share on other sites
quote:
Original post by eldee
first off, that''s not a parse error.. int main() must return a value.

Sort of. main() must indeed return a value, but keep in mind that if the main() function does not explicitly return a value, it will implicitly return 0 once control reaches the end of the function.

quote:

also- there are no other "parse" errors in that code.
if you dont post the code verbatem, then you''re pissing in the metaphorical wind.

Unless -- and this is, of course, a guess -- he forgot to #include the proper header:
#include <iostream>using namespace std; // Good for newbies ...

##### Share on other sites
quote:
Original post by dchar3
here it is, due to popular demand, the source code for Dev C++ 4 compiler! but i dont think its exactly right.

If it was exactly right, you wouldn''t be posting about a problem!
quote:

int main()
{
cout << "I cant remember this part";
}

Please post the *exact* code along with the message that your compiler produces. At the very least, you need to include iostream and namespace-qualify cout.
quote:
Original post by eldee
first off, that''s not a parse error.. int main() must return a value.

Unlike other functions, main() does not have to return a value. If no value is returned, the compiler should insert a "return 0" on your behalf.
quote:

also- there are no other "parse" errors in that code.

Well, there''s no headers, but until the OP posts what I asked for, he''s wasting everyone''s time.

##### Share on other sites
I think that is the entire code of the OP. I''m guessing he didn''t include any header files and that''s why he''s getting the error, meaning that he did do exactly what we asked him to do and now he knows the problem. The ''beginners'' forum works again.

##### Share on other sites
Some aspect of your code is incomplete. A function is spelled wrong, or you have a problem with puncuation marks. This means that the compiler is having a problem with a statement. Here is an example.
//There is an error here.
cout<<
It should say something like this:
In line 2, parse error.

Scott Simontis
Game Programmer in Training
Have a nice day!
Current Project: Waiting for OpenGL Game Programming Book

##### Share on other sites
quote:
Original post by kdogg
I think that is the entire code of the OP.

I didn''t just ask for the code.

##### Share on other sites
quote:
Original post by Miserable
Sort of. main() must indeed return a value, but keep in mind that if the main() function does not explicitly return a value, it will implicitly return 0 once control reaches the end of the function.

Any idea why the committee felt they had to introduce a special rule for main? Allowing void main instead would have made more sense.

AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.

##### Share on other sites
quote:
Original post by Arild Fines

What? Why?

[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]

##### Share on other sites
Because it doesn''t require main to exhibit special "magic" behavior?

##### Share on other sites
quote:
Original post by Arild Fines
Any idea why the committee felt they had to introduce a special rule for main?

Because of especially idiotic backward-compatibility considerations. The committee wanted to keep compatibility with certain K&R programs which omitted the return-value. Only, those programs still won''t compile since they also omit a return-type. Clever, huh?
quote:

Or not special-casing main().

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627638
• Total Posts
2978327

• 10
• 12
• 22
• 13
• 34