Author Topic: 2 basic C::B questions from a newbie  (Read 6892 times)

Offline temujin

  • Single posting newcomer
  • *
  • Posts: 5
2 basic C::B questions from a newbie
« 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.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: 2 basic C::B questions from a newbie
« Reply #1 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".
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline lubos

  • Almost regular
  • **
  • Posts: 131
Re: 2 basic C::B questions from a newbie
« Reply #2 on: August 15, 2007, 06:46:23 pm »
you can disable it in project->properties->build target->pause when execution ends  :)

Offline temujin

  • Single posting newcomer
  • *
  • Posts: 5
Re: 2 basic C::B questions from a newbie
« Reply #3 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.

Offline lubos

  • Almost regular
  • **
  • Posts: 131
Re: 2 basic C::B questions from a newbie
« Reply #4 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

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: 2 basic C::B questions from a newbie
« Reply #5 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...
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: 2 basic C::B questions from a newbie
« Reply #6 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 !!!

Offline temujin

  • Single posting newcomer
  • *
  • Posts: 5
Re: 2 basic C::B questions from a newbie
« Reply #7 on: August 15, 2007, 10:13:52 pm »
Thanks to all!!


t.