By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,827 Members | 2,177 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,827 IT Pros & Developers. It's quick & easy.

"Hello, world!" tutorial available (Windows, mingw/msvc)

P: n/a
Just because there seems to be a lack of post-standard _correct_
tutorials: <url: http://home.no.net/dubjai/win32cpptut/>.

Disclaimer: written this evening so perhaps there are "bugs" in the
presentation -- are there?

Plea: if someone takes the time to convert the word document to clean
xhtml perhaps with stylish clear readable layout, then it will be an
incentive for me to go on to write a next part, and a next part...

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #1
Share this Question
Share on Google+
21 Replies


P: n/a
That's a good idea Alf.

By the way:

"As you become more experienced you will appreciate the comforts of an IDE
(Integrated Development Environment) such as Visual Studio, or (free)
DevC++ or (free) Eclipse, because then you know enough to make it do your
bidding, but for now I recommend you stay with command line tools only so
that you learn what goes on ?under the hood? and have full control."

Exactly my thoughts (I can tell, because I did the same mistake and started
off with a fully fledged IDE (VC++6), used it for like 3 years and was
totally clueless when first using command line g++).

One cosmetic thing: The exact name behind MinGW32 is "Minimalist GNU for
Win32". But maybe I'm just nitpicking here :)

Regards,
Matthias

Alf P. Steinbach wrote:
Just because there seems to be a lack of post-standard _correct_
tutorials: <url: http://home.no.net/dubjai/win32cpptut/>.

Disclaimer: written this evening so perhaps there are "bugs" in the
presentation -- are there?

Plea: if someone takes the time to convert the word document to clean
xhtml perhaps with stylish clear readable layout, then it will be an
incentive for me to go on to write a next part, and a next part...


Jul 22 '05 #2

P: n/a
Why restrict the tutorial to Windows?
I'd suggest to provide for each program:
+ the explaine program itself
+ compilation under Windows
+ compilation under Unix

Of course then there should be a section that deals with the
installation of the complier and the development environment.

If you don't insist on XHTML I'll convert your document to HTML
(and later upgrade to XHTLM which I'm not familiar with :-)

Regards,
Stephan Brönnimann
br****@osb-systems.com
http://www.osb-systems.com
Open source rating and billing engine for
communication networks.

Jul 22 '05 #3

P: n/a
Alf P. Steinbach wrote:
Just because there seems to be a lack of post-standard _correct_
tutorials: <url: http://home.no.net/dubjai/win32cpptut/>.

Disclaimer: written this evening so perhaps there are "bugs" in the
presentation -- are there?

Plea: if someone takes the time to convert the word document to clean
xhtml perhaps with stylish clear readable layout, then it will be an
incentive for me to go on to write a next part, and a next part...


#include <iostream> // std::cout
#include <ostream> // std::endl

int main()
{
std::cout << "Hello, world!" << std::endl;
}

<iostream> contains both cout and endl, so remove ostream from there.


--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #4

P: n/a
Alf P. Steinbach wrote:
Just because there seems to be a lack of post-standard _correct_
tutorials: <url: http://home.no.net/dubjai/win32cpptut/>.

Disclaimer: written this evening so perhaps there are "bugs" in the
presentation -- are there?

Plea: if someone takes the time to convert the word document to clean
xhtml perhaps with stylish clear readable layout, then it will be an
incentive for me to go on to write a next part, and a next part...

Also the tutorial is too long for a "hello world" program.


--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #5

P: n/a
Ioannis Vranos wrote in news:1102776232.29255@athnrd02 in comp.lang.c++:
Alf P. Steinbach wrote:
Just because there seems to be a lack of post-standard _correct_
tutorials: <url: http://home.no.net/dubjai/win32cpptut/>.

Disclaimer: written this evening so perhaps there are "bugs" in the
presentation -- are there?

Plea: if someone takes the time to convert the word document to clean
xhtml perhaps with stylish clear readable layout, then it will be an
incentive for me to go on to write a next part, and a next part...


#include <iostream> // std::cout
#include <ostream> // std::endl

int main()
{
std::cout << "Hello, world!" << std::endl;
}

<iostream> contains both cout and endl, so remove ostream from there.


That isn't what my copy of the standard (27.3) says:

Header <iostream> synopsis

namespace std {
extern istream cin;
extern ostream cout;
extern ostream cerr;
extern ostream clog;
extern wistream wcin;
extern wostream wcout;
extern wostream wcerr;
extern wostream wclog;
}

But maybe I missed something, if so what ?

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #6

P: n/a
>But maybe I missed something, if so what ?

How could <iostream> define all these variables without the appropiate
extra headers? I think that would violate the grammar rules.

Jul 22 '05 #7

P: n/a
Razzer wrote in news:11**********************@z14g2000cwz.googlegr oups.com
in comp.lang.c++:
But maybe I missed something, if so what ?


How could <iostream> define all these variables without the appropiate
extra headers? I think that would violate the grammar rules.


Its a Standard header it can do it by magic.

IOW the Standard doesen't care how its done, just that it is done.

Besides std::endl isn't a member of std::ostream so it isn't needed
inorder to declare a usable std::cout object.

In fact I don't realy see anything in the standard that would require
std::cout to be usable (i.e. that std::ostream is a *complete* type)
after only including <iostream>, since the only requirement seems to
be that the objects are declared.

27.3/1:

The header <iostream> declares objects that associate objects
with the standard C streams provided for by the functions declared
in <cstdio> (27.8.2).

Also note there are implementations in which std::endl *is not*
available after only including <iostream>.

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #8

P: n/a

"Ioannis Vranos" <iv*@remove.this.grad.com> wrote in message
news:1102776232.29255@athnrd02...
Alf P. Steinbach wrote:
Just because there seems to be a lack of post-standard _correct_
tutorials: <url: http://home.no.net/dubjai/win32cpptut/>.

Disclaimer: written this evening so perhaps there are "bugs" in the
presentation -- are there?

Plea: if someone takes the time to convert the word document to clean
xhtml perhaps with stylish clear readable layout, then it will be an
incentive for me to go on to write a next part, and a next part...


#include <iostream> // std::cout
#include <ostream> // std::endl

int main()
{
std::cout << "Hello, world!" << std::endl;
}

<iostream> contains both cout and endl, so remove ostream from there.


<iostream> delcares 'cin' and 'cout' (and other objects).
The manipulator 'endl' is declared by <ostream>. While most
implementations I've seen will let you get away with using
'endl' without #including <ostream>, it's still technically
incorrect.

-Mike
Jul 22 '05 #9

P: n/a
>Its a Standard header it can do it by magic.

I can certainly understand that, however...
Besides std::endl isn't a member of std::ostream so it isn't needed
inorder to declare a usable std::cout object.
This is a better point.
In fact I don't realy see anything in the standard that would require
std::cout to be usable (i.e. that std::ostream is a *complete* type)
after only including <iostream>, since the only requirement seems to
be that the objects are declared.


I think it is just of a reflection of how I read the Standard. I read
the synopsis of the <iostream> header file, and I see various
"extern"s. To me, this implies that a compiler needs to follow the
extern sematics, which would require a complete type.

Jul 22 '05 #10

P: n/a
* Ioannis Vranos:
Alf P. Steinbach wrote:
Just because there seems to be a lack of post-standard _correct_
tutorials: <url: http://home.no.net/dubjai/win32cpptut/>.

Disclaimer: written this evening so perhaps there are "bugs" in the
presentation -- are there?

Plea: if someone takes the time to convert the word document to clean
xhtml perhaps with stylish clear readable layout, then it will be an
incentive for me to go on to write a next part, and a next part...

Also


?

the tutorial is too long for a "hello world" program.


Well I think that might be the soundbite syndrome.

By now you've seen that even for the program text itself, which is
trivial and IMHO not the main point of "Hello, world", there was a new
thing to be learned for you (unfortunately also for many textbook authors).

What should I remove from the rest, do you think?

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #11

P: n/a
* Matthias =?ISO-8859-1?Q?K=E4ppler?=:
[top-posting]
Don't top post. See the FAQ. Corrected.
* Matthias =?ISO-8859-1?Q?K=E4ppler?=: * Alf P. Steinbach:
Just because there seems to be a lack of post-standard _correct_
tutorials: <url: http://home.no.net/dubjai/win32cpptut/>.
That's a good idea Alf.


Apparently it was... ;-)

I did it because it's so often been the case that some ages-old
incorrect tutorial was to blame for questions here.

Latest now in the thread
«Beginnger: frustration right at the "Hello world" step!»...

[snip] One cosmetic thing: The exact name behind MinGW32 is "Minimalist GNU for
Win32". But maybe I'm just nitpicking here :)


Thanks. I've corrected that, and also some speling erors, and added
a link to the Windows compiled help format documentation of GNU tools
because the link to that from the mingw pages was broken. I just
replaced the earlier version.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #12

P: n/a
* =?iso-8859-1?q?Stephan_Br=F6nnimann?=:

Why restrict the tutorial to Windows?
You have a point. I think Mac people could benefit from a corresponding
tutorial for the Mac. On the other hand, if someone is running Linux,
then I think chances are that such a tutorial isn't needed (even though
both OS/X and Linux are *nix the kind of user and how it's used is very
different).

The reason I write for Windows is that that's what I'm best at.

The reason I think system-specific details are important in learning how
to use the tools is that there are no system-independent tools -- the
main hurdles are system-specific. The reason I think system-specific
details are important in learning how to use C++ (I've not come to that
yet...) is that doing system-specific things is a main reason for using
C++, and what C++ is traditionally used for. Otherwise one could just
as well use e.g. Java. For example, "The UNIX Programming Environment",
by Kernighan and Pike, was a great book to learn what C was all about.
Placing the language and its practical application in context -- what
to use it for, and what not.

I'd suggest to provide for each program:
+ the explaine program itself
+ compilation under Windows
+ compilation under Unix
I think compilation under Unix is pretty well covered by showing how
it's done using g++?

Of course then there should be a section that deals with the
installation of the complier and the development environment.
Is there any *nix, with the possible exception of Max OS/X, that doesn't
have a C++ compiler installed?

If you don't insist on XHTML I'll convert your document to HTML
(and later upgrade to XHTLM which I'm not familiar with :-)


Thanks, that would be great. XHTML is just a very well-defined and
somewhat restricted form of HTML. The reasons I think XHTML could be
better for this are that (1) HTML often becomes very browser-specific,
and (2) XHTML is probably _much_ better suited for further conversion,
and (3) XHTML is the current HTML standard: the old HTML is
yestercentury's technology... ;-)

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #13

P: n/a
Alf P. Steinbach wrote:
Is there any *nix, with the possible exception of Max OS/X, that doesn't
have a C++ compiler installed?

I do not think Mac OS X has not a C++ compiler. In a local COMDEX 2-3
years ago, I came across some Mac laptops with OS X at a Macintosh
booth, and checked it. I opened a console window and if i recall well it
had both gcc and g++.

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #14

P: n/a

"Alf P. Steinbach" <al***@start.no> wrote in message
news:41***************@news.individual.net...
[SNIP]
the tutorial is too long for a "hello world" program.
Well I think that might be the soundbite syndrome.

By now you've seen that even for the program text itself, which is
trivial and IMHO not the main point of "Hello, world", there was a new
thing to be learned for you (unfortunately also for many textbook

authors).
What should I remove from the rest, do you think?


Well, this might be nit-picking but I´d put in the return statement in the
main function. We all know that it can be omitted for main() but IMHO a
newbie might be mislead. In the text it says that the default return value
is zero and that main returns an int. But due to the missing statement
people might think that this is the default behavior for all functions
and/or that the infamous void main(), which is seen way too often, is also
okay.

Cheers
Chris
Jul 22 '05 #15

P: n/a
Alf P. Steinbach wrote:
Is there any *nix, with the possible exception of Max OS/X, that doesn't
have a C++ compiler installed?


Actually, I think quite a lot, on a fresh installation at least :)
C++ is actually not very common in the Linux/Unix camp. Almost *everything*
is written in C, because C was the original implementation language of
Unix. I think both were developed at the same time, maybe it's some sort of
"traditional" thing.

However, since the installation procedure of packages may completely differ
from one Unix to others, I don't think it's necessary to describe how to
install g++. The reader should know his system well enough to know how to
install packages.
Jul 22 '05 #16

P: n/a
In article <cp*************@news.t-online.com>,
Matthias =?ISO-8859-1?Q?K=E4ppler?= <no****@digitalraid.com> wrote:
Alf P. Steinbach wrote:
Is there any *nix, with the possible exception of Max OS/X, that doesn't
have a C++ compiler installed?
Actually, I think quite a lot, on a fresh installation at least :)


Same for C then.... you're right, it's up to the vendor.
C++ is actually not very common in the Linux/Unix camp. Almost *everything*
is written in C, because C was the original implementation language of
Unix. I think both were developed at the same time, maybe it's some sort of
"traditional" thing.


Some 15 or more years seperate the general public releases of the 2.
--
Greg Comeau / Comeau C++ 4.3.3, for C++03 core language support
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Jul 22 '05 #17

P: n/a
Greg Comeau wrote:
Some 15 or more years seperate the general public releases of the 2.


C and Unix? ^^
Jul 22 '05 #18

P: n/a
In article <cp*************@news.t-online.com>,
Matthias =?ISO-8859-1?Q?K=E4ppler?= <no****@digitalraid.com> wrote:
Greg Comeau wrote:
Some 15 or more years seperate the general public releases of the 2.


C and Unix? ^^


Sorry, I meant between C and C++.
--
Greg Comeau / Comeau C++ 4.3.3, for C++03 core language support
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Jul 22 '05 #19

P: n/a
In article <41***************@news.individual.net>,
Alf P. Steinbach <al***@start.no> wrote:

Is there any *nix, with the possible exception of Max OS/X, that doesn't
have a C++ compiler installed?


Mac OS X does not come with a C++ compiler (or indeed any compilers)
installed by default. However, retail packages of OS X include an "XCode
Tools" CD that can be installed as an option. It includes a suite of
development tools including a C++ compiler (g++). Disk images of that CD
can also be downloaded for free from Apple's Web site.

--
Jon Bell <jt*******@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
Jul 22 '05 #20

P: n/a
* Alf P. Steinbach:
Just because there seems to be a lack of post-standard _correct_
tutorials: <url: http://home.no.net/dubjai/win32cpptut/>.

Disclaimer: written this evening so perhaps there are "bugs" in the
presentation -- are there?

Plea: if someone takes the time to convert the word document to clean
xhtml perhaps with stylish clear readable layout, then it will be an
incentive for me to go on to write a next part, and a next part...


Thanks to the good work of Stephan Brönnimann in converting Word to
HTML the document is now available in HTML format, at

HTML format: <url: http://home.no.net/dubjai/win32cpptut/html/>.

There's also a second part, about variables, but so far only in Word.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #21

P: n/a
You'll get the 2nd part, just give me some time to do my own work too
:-)

Stephan

[OT]
I'm having problems seeing my own messages, and if I'm looking at
other threads it seems some postings just get lost.
Is anybody experiencing similar problems when posting via Google?
[OT]

Jul 22 '05 #22

This discussion thread is closed

Replies have been disabled for this discussion.