Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Computer Forums > Software Programming
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

Software Programming Software programming talk, ask questions about computer software programming or help others

Google
Closed Thread
 
LinkBack Thread Tools Display Modes
Old 06-12-2007, 9:43 PM   #1
Frithjof Engel
 
Frithjof Engel's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Am I doing this right???

On Tue, 15 Jul 2003 20:50:36 -0700, Mario <tahomaoso@lvcm.com> wrote:
> Make sure that's not all you're typing...
>
> #include <iostream.h>
> int main()
> {
> cout<<"what ever you want to write";
> return 0;
> }
> The above should work, provided that you have set up your compiler
> correctly.


That's deprecated. The current ISO standard says, that all stdlib
stuff is in a namespace called std. The above example should look like:

#include <iostream> // note: without '.h'
using namespace std;

int main()
{
cout<<"Hello World";
return 0;
}
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Advertisements
Old 06-12-2007, 9:44 PM   #2
AngleWyrm
 
AngleWyrm's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Am I doing this right???

"Frithjof Engel" <frithjof@fms-engel.de> wrote in message news:bhbeth$ung3c$1@news.hansenet.net...
> That's deprecated. The current ISO standard says, that all stdlib
> stuff is in a namespace called std. The above example should look like:
>
> #include <iostream> // note: without '.h'
> using namespace std;
>
> int main()
> {
> cout<<"Hello World";
> return 0;
> }


That's unnecessary; the return on main, if it is not actually being used, may be completely omitted.
Here's a quote from "The C++ Programming Language" by Bjarne Stroustrup, the author of C++ language:
"The int value returned by main(), if any, is the program's return value to "the syttem." If no
value is returned, the system will received a value indication successful completion."
[section 3.2, pp46]

Thus the following is a valid version:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, World" << endl;
}


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 06-12-2007, 9:44 PM   #3
R. Alan Monroe
 
R. Alan Monroe's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Am I doing this right???

In article <BRF%a.37716$2x.3841@rwcrnsc52.ops.asp.att.net>, "AngleWyrm" <no_spam_anglewyrm@hotmail.com> wrote:
>"The int value returned by main(), if any, is the program's return value to
> "the syttem." If no


If that's the case, maybe your program should read:
cout << "Don't disturb this groove!" << endl;

:^)

Alan
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 06-12-2007, 9:44 PM   #4
John R. Strohm
 
John R. Strohm's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Am I doing this right???

"AngleWyrm" <no_spam_anglewyrm@hotmail.com> wrote in message
news:BRF%a.37716$2x.3841@rwcrnsc52.ops.asp.att.net ...
> "Frithjof Engel" <frithjof@fms-engel.de> wrote in message

news:bhbeth$ung3c$1@news.hansenet.net...
> > That's deprecated. The current ISO standard says, that all stdlib
> > stuff is in a namespace called std. The above example should look like:
> >
> > #include <iostream> // note: without '.h'
> > using namespace std;
> >
> > int main()
> > {
> > cout<<"Hello World";
> > return 0;
> > }

>
> That's unnecessary; the return on main, if it is not actually being used,

may be completely omitted.
> Here's a quote from "The C++ Programming Language" by Bjarne Stroustrup,

the author of C++ language:
> "The int value returned by main(), if any, is the program's return value

to "the syttem." If no
> value is returned, the system will received a value indication successful

completion."
> [section 3.2, pp46]
>
> Thus the following is a valid version:
> #include <iostream>
> using namespace std;
> int main()
> {
> cout << "Hello, World" << endl;
> }


This is the kind of ad-hoc hackery that I despise about C and C++.

Here we have a procedure, that is declared as returning a value
(specifically, an int), and there is no "return" statement anywhere in
sight.

This is, to a SANE language, a self-evident error on the programmer's part.

My question: Is this a special case just for a procedure named "main", or is
this a special case for any procedure with a signature "int XXX(void)" or
"int XXX(unspecified)", or what?

And observe, if the special case is only for procedure "main", what happens
if we decide to change "main" to something else, to put a wrapper around it?
Is it now erroneous, or do we just return garbage to the enclosing main()?


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 06-12-2007, 9:44 PM   #5
AngleWyrm
 
AngleWyrm's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Am I doing this right???

"John R. Strohm" <strohm@airmail.net> wrote in message news:bhp6ru$qg4@library2.airnews.net...
> "AngleWyrm" <no_spam_anglewyrm@hotmail.com> wrote in message
> news:BRF%a.37716$2x.3841@rwcrnsc52.ops.asp.att.net ...
> > "Frithjof Engel" <frithjof@fms-engel.de> wrote in message

> news:bhbeth$ung3c$1@news.hansenet.net...
> This is the kind of ad-hoc hackery that I despise about C and C++.
>
> Here we have a procedure, that is declared as returning a value
> (specifically, an int), and there is no "return" statement anywhere in
> sight.
>
> This is, to a SANE language, a self-evident error on the programmer's part.
>
> My question: Is this a special case just for a procedure named "main", or is
> this a special case for any procedure with a signature "int XXX(void)" or
> "int XXX(unspecified)", or what?


Yes, this is a special case, specifically for the program entry point called "main". It may be true
that not explicitly declaring a return could be construed as confusing, and therefore possibly bad
programming practice. It might also be acceptable to say that it is a default that is almost never
used.

C++ has the marks of evolution within it's existance. For instance, the wchar_t is a rather strange
way to name a basic variable type; it seems like it would have been more orthagonal to name it
wchar, and leave it at that.


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 06-12-2007, 11:21 PM   #6
Eternal Vigilance
 
Eternal Vigilance's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Am I doing this right???



AngleWyrm wrote:

> "John R. Strohm" <strohm@airmail.net> wrote in message news:bhp6ru$qg4@library2.airnews.net...
> > "AngleWyrm" <no_spam_anglewyrm@hotmail.com> wrote in message
> > news:BRF%a.37716$2x.3841@rwcrnsc52.ops.asp.att.net ...
> > > "Frithjof Engel" <frithjof@fms-engel.de> wrote in message

> > news:bhbeth$ung3c$1@news.hansenet.net...
> > This is the kind of ad-hoc hackery that I despise about C and C++.
> >
> > Here we have a procedure, that is declared as returning a value
> > (specifically, an int), and there is no "return" statement anywhere in
> > sight.
> >
> > This is, to a SANE language, a self-evident error on the programmer's part.
> >
> > My question: Is this a special case just for a procedure named "main", or is
> > this a special case for any procedure with a signature "int XXX(void)" or
> > "int XXX(unspecified)", or what?

>
> Yes, this is a special case, specifically for the program entry point called "main". It may be true
> that not explicitly declaring a return could be construed as confusing, and therefore possibly bad
> programming practice. It might also be acceptable to say that it is a default that is almost never
> used.
>
> C++ has the marks of evolution within it's existance. For instance, the wchar_t is a rather strange
> way to name a basic variable type; it seems like it would have been more orthagonal to name it
> wchar, and leave it at that.


I just try to ignore all this bizaare C++ crap and go on programming in C like I always have.

Template ... whats that??? etc..

Of course since Im from the old days, I know how to write my own library routines
from the bottom up (beside the programming I do wouldnt be helped much by all that generalized
wigetry anyway...) I do use things like DirectX, but manage to avoid most of the C++ OOP
gunk for the majority of the data crunching stuff (AI etc...)

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Featured Websites
Free Space
Free Space
Free Space Free Space
Closed Thread
Tags: ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Featured Websites




All times are GMT +1. The time now is 12:43 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98