|
From: Ioannis V. <no...@ya...> - 2001-05-28 08:58:21
|
We are talking about C++.
<cstdlib>, <cctype> e.t.c. have the C library functions defined in
namespace std. So, if you want to use printf using <cstdio> you should
write:
#include <cstdio>
int main()
{
using std::printf;
// or using namespace std;
printf("Hello World!\n");
}
If you use <stdio.h> e.t.c. you do not need to use the using statement.
For example:
#include <stdio.h>
int main()
{
printf("Hello World!\n");
}
The C subset header files of C++ with the .h extension are defined with
something like this:
--- stdio.h ---
#include <cstdio>
using std::printf;
// ...
Now C++ standard library uses only headers without extensions with the
need of using statement.
For example:
#include <iostream> // Correct
// ...
#include <iostream.h> // Incorrect in ANSI C++ (1998)!
Hope this helps.
Ioannis
* Ioannis Vranos
* Programming pages: http://members.nbci.com/noicys
* Alternative URL: http://run.to/noicys
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of Luigi
Santillo
Sent: Saturday, May 26, 2001 9:15 PM
To: dev...@li...
Subject: Re: [Dev-C++] BAKERY PROBLEM
Hi,
I took a look at Vassili's solution.
At the beginning of the (attached) file there are the lines:
-----------
...
#include <cstdlib>
#include <cctype>
-----------
I would have included the files: stdlib.h and ctype.h instead of cstdlib
and cctype.
Is there anything wrong with my approach?
At 17.42 26/05/01 +0100, you wrote:
>----- Original Message -----
>From: <mailto:LO5...@ao...>LO5...@ao...
>To:
><mailto:dev...@li...>dev...@li...
orge.net
>
>Sent: Friday, May 25, 2001 4:22 PM
>Subject: Fwd: [Dev-C++] BAKERY PROBLEM
>
>#include <iostream.h>
>#include <stdlib.h>
>const char a = 61;
>const int SENNTINEL= -999;
>const char SKIP =' ';
> ...
--
gisan
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|