Code::Blocks Forums
User forums => General (but related to Code::Blocks) => Topic started 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.
-
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".
-
you can disable it in project->properties->build target->pause when execution ends :)
-
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.
-
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
-
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...
-
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 !!!
-
Thanks to all!!
t.