|
 |
|
 |
05-12-2003, 12:27 PM
|
#1 (permalink)
|
|
Registered User
Join Date: Apr 2003
Location: Baltimore, Md
Posts: 2
|
grr... stupid linux
So im writing a dumb little program to test some libraries i just wrote. I'm new to writing code under linux but i know you have to return an exit status thingy. All the code i've pretty much ever seen ended with either
return 0;
or
return EXIT_SUCCESS;
which i presume to just be defined as 0.
however, whenever i do any of these, gcc still ALWAYS tells me that "main() must return int." and wont compile. I've tried
just about every variation of return 0; that you can imagine, it just still wont compile!
what the heck am i doing wrong?
thanks!
-jordan
|
|
|
05-12-2003, 12:36 PM
|
#2 (permalink)
|
|
Registered User
Join Date: Apr 2003
Location: Baltimore, Md
Posts: 2
|
oops
ok, so i can anwser my own question.
just becuase i was taught to always make main void, doesnt mean its right.
Stupid comp. sci. teacher.
so, from now on:
int main() {
return 0;
}
yes?
yes.
Thank you.
-Jordan
|
|
|
05-12-2003, 08:59 PM
|
#3 (permalink)
|
|
Regular Contributor
Join Date: Feb 2003
Posts: 120
|
Yes, standard calls for main. main should not return void. although, will work with older compilers, newer compilers will only want int main and will complain about anything else.
|
|
|
05-12-2003, 10:17 PM
|
#4 (permalink)
|
|
Non-profit Techie
Join Date: Dec 2002
Location: Mesa AZ
Posts: 76
|
C was changed to return an int instead of void when it went ot ANSI C standard.
|
|
|
05-18-2003, 02:52 PM
|
#5 (permalink)
|
|
Registered User
Join Date: Mar 2003
Posts: 31
|
Yeah. The first thing you should know about high school "computer science" is that they teach you everything incorrectly. That seems to the collective of all experiences I've gathered.
|
|
|
05-18-2003, 06:24 PM
|
#6 (permalink)
|
|
I am red.
Join Date: Feb 2003
Location: Cleveland, OH
Posts: 139
|
well..... true but not entirely
See, I loved high school computer science, all the theory and algorithms they teach (in my experience) were correct and infinitely useful.
HOWEVER
The classes they use to teach vectors and such (apvector, apstack etc..) will completely screw you up later. If you're coming out of AP comp sci and going into college and haven't done coding outside that this transition is (as it was for me) the hardest part of getting into college programming courses.
I spent literally days trying to figure out what the hell a namespace was and why it should be std and then what it actually did.
There were good reasons for why the college board did things this way but that reason is being eliminated because the AP Comp Sci test and therefor the course is being switched over to Java.
|
|
|
05-18-2003, 08:33 PM
|
#7 (permalink)
|
|
Regular Contributor
Join Date: Feb 2003
Posts: 120
|
Re: well..... true but not entirely
Quote:
Originally posted by saline
See, I loved high school computer science, all the theory and algorithms they teach (in my experience) were correct and infinitely useful.
HOWEVER
The classes they use to teach vectors and such (apvector, apstack etc..) will completely screw you up later. If you're coming out of AP comp sci and going into college and haven't done coding outside that this transition is (as it was for me) the hardest part of getting into college programming courses.
I spent literally days trying to figure out what the hell a namespace was and why it should be std and then what it actually did.
There were good reasons for why the college board did things this way but that reason is being eliminated because the AP Comp Sci test and therefor the course is being switched over to Java.
|
very true. I am glad that I have ventured out of the class and went on web boards. Otherwise, I would be like my other classmates that plan to do CS, CpE, or EE. I'm glad I programmed out of class, because those classes would screw some people over. i.e. your example of namespace std, etc. The ap classes don't have certain fxns that the c++ libraries do. I wrote some code on the side during free time in class, and classmates were asking me what std:: stuff was, or namespace, or why int main(). (My teacher taught void main, she knew it was int main, but she thought it would be easier for people to understand void main; ah whatever, she's still a great programmer, awesome teacher). I wish them the best, but it may take them a while to pick up on college programming classes, if taught in C++.
|
|
|
05-18-2003, 08:34 PM
|
#8 (permalink)
|
|
Regular Contributor
Join Date: Feb 2003
Posts: 120
|
Quote:
Originally posted by Antagony
Yeah. The first thing you should know about high school "computer science" is that they teach you everything incorrectly. That seems to the collective of all experiences I've gathered.
|
The algorithms and such were taught to me well. Only a few things I can complain about, but mostly through the collegeboard code.
|
|
|
05-18-2003, 10:37 PM
|
#9 (permalink)
|
|
Non-profit Techie
Join Date: Dec 2002
Location: Mesa AZ
Posts: 76
|
If you have a good program logic an design class to set your basics then it doesn't really matter what language or specific Headers or API's you use in school. The art is constantly changing and as a programmer you need to be able to adjust to the current standards. I learned programming in basic on an old IBM back in the late 70's, but I have ben able to apply or adapt the basic programming logic as the languages have changed.
we still have for loops and if- else loops and when- if loops and conditonals, those haven't changed, mainly it is the way we look at the data or the information that we are working with that has changed.
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -8. The time now is 12:01 PM.
|
Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
|
 |
|