Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: temujin on August 15, 2007, 06:12:55 pm

Title: 2 basic C::B questions from a newbie
Post by: temujin on August 15, 2007, 06:12:55 pm
Dear Forum,

I´m a newbie just starting with C::B to learn C++, wondering about 2 things when compiling and running the standard console program ("Hello World").

#include <iostream>

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


1. Where is the code that says "press ENTER to continue" in the output, and how can I disable it? (...yes, I tried to search previous posts).

2. Why do I have to include <iostream> and not <iostream.h>? I thought  this was only possible when explicitly using the namespace in which the library residesin.

best regards
t.
Title: Re: 2 basic C::B questions from a newbie
Post by: thomas on August 15, 2007, 06:16:02 pm
1. is done by Code::Blocks, it has nothing to do with your program. If you run your program elsewhere, it will not appear.
2. This is the C++ standard for.... 5? 6? years now. There is no reason other than "this is how it is".
Title: Re: 2 basic C::B questions from a newbie
Post by: lubos on August 15, 2007, 06:46:23 pm
you can disable it in project->properties->build target->pause when execution ends  :)
Title: Re: 2 basic C::B questions from a newbie
Post by: temujin on August 15, 2007, 06:50:44 pm
2. This is the C++ standard for.... 5? 6? years now. There is no reason other than "this is how it is".

Thanks...How do I know which libraries need the .h extension and wich that don´t? E.g.  including windows I need <windows.h>

regards
t.
Title: Re: 2 basic C::B questions from a newbie
Post by: lubos on August 15, 2007, 07:42:34 pm
2. This is the C++ standard for.... 5? 6? years now. There is no reason other than "this is how it is".

Thanks...How do I know which libraries need the .h extension and wich that don´t? E.g.  including windows I need <windows.h>

regards
t.

c++ standard headers are without .h
Title: Re: 2 basic C::B questions from a newbie
Post by: thomas on August 15, 2007, 08:42:45 pm
Everything that is not C++ standard, i.e. all Windows headers, all C headers, and anything "old school" take .h. You should use the extension for your own headers too.
Thus, you will want: <windows.h>, <stdio.h>, <stddef.h>, <emmintrin.h> etc...

However, the C++ standard library headers have no extension, so if you use these, you want
<iostream>, <vector>, <map>, <algorithm>, etc...
Title: Re: 2 basic C::B questions from a newbie
Post by: killerbot on August 15, 2007, 08:44:50 pm
also c headers (when using in c++ code/compiler) are without .h and you need to put a c in front of them !!

Examples :
<stdio.h> --> <cstdio>
<stdlib.h> --> <cstdlib>

and then everything is available in the std namespace !!!
Title: Re: 2 basic C::B questions from a newbie
Post by: temujin on August 15, 2007, 10:13:52 pm
Thanks to all!!


t.