473,320 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Why does this work?!?

I thought system("PAUSE"); was part of stdlib.h and cstdlib. Then why does
this work? :

#include <iostream>
using namespace std;
int main()
{
cout << "hello, world" << endl;
system("PAUSE");
return 0;
}

It seems that system is part of iostream?!? that's news to me!
Jul 22 '05 #1
5 1582
On Tue, 9 Dec 2003 23:38:43 -0500, "Mark Bruno"
<br*********@comcast.net> wrote in comp.lang.c++:
I thought system("PAUSE"); was part of stdlib.h and cstdlib. Then why does
this work? :

#include <iostream>
using namespace std;
int main()
{
cout << "hello, world" << endl;
system("PAUSE");
return 0;
}

It seems that system is part of iostream?!? that's news to me!


Just one of the quiet changes in C++ from C. The C language standard
specifically prohibits any standard header from including any other
standard header. The C++ language standard, OTOH, specifically allows
ANY standard header to include any or all other standard headers at
the discretion of the implementors. So <iostream> including <cstdlib>
or <stdlib.h> is perfectly legal behavior for your compiler.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
Jul 22 '05 #2
"Mark Bruno" <br*********@comcast.net> wrote in message
news:Hf********************@comcast.com
I thought system("PAUSE"); was part of stdlib.h and cstdlib. Then
why does this work? :

#include <iostream>
using namespace std;
int main()
{
cout << "hello, world" << endl;
system("PAUSE");
return 0;
}

It seems that system is part of iostream?!? that's news to me!


This may vary from one system to another, but on VC++ 7.0:

iostream includes istream
istream include ostream
ostream includes ios
ios includes xlocnum
xlocnum includes cstdlib
--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)
Jul 22 '05 #3

"Mark Bruno" <br*********@comcast.net> wrote in message
news:Hf********************@comcast.com...
I thought system("PAUSE"); was part of stdlib.h and cstdlib. Then why does this work? :

#include <iostream>
using namespace std;
int main()
{
cout << "hello, world" << endl;
system("PAUSE");
return 0;
}

It seems that system is part of iostream?!? that's news to me!


try tracing the #includes from <iostream>
Jul 22 '05 #4
Thanks guys, you explained it perfectly. I guess I should always add
#include <cstdlib> in such a scenario for compiler compatibility?
Jul 22 '05 #5
"Mark Bruno" <br*********@comcast.net> wrote in message
news:f6********************@comcast.com
Thanks guys, you explained it perfectly. I guess I should always add
#include <cstdlib> in such a scenario for compiler compatibility?


In order to guarantee that system will be declared, yes.
--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)
Jul 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jonas | last post by:
This works fine in Win XP but does not work at all in Win 98. Private WithEvents objIExplorer As InternetExplorer I have to do it like this to get it to work in Win 98 Dim objIExplorer As...
3
by: Julian | last post by:
Hi I am trying to update a date field in my table but some how this simple code does not work, I know the select work because if I write the fields, it will show the data from the table but why...
5
by: me | last post by:
I have a Class Library that contains a Form and several helper classes. A thread gets created that performs processing of data behind the scenes and the Form never gets displayed (it is for debug...
22
by: Robert Bralic | last post by:
CAN anybody tell me any address where I can download some small(1000-2000) lines C++ proghram source. Or send me ,a small(1000-2000) lines C++ program source that I can compille with gpp under...
12
by: Frank Hauptlorenz | last post by:
Hello Out there! I have a DB2 V7.2 Database (Fix11) on Win 2000 Professional. It was before a NT 4 based Domain - now it is a Win 2000 Domain. The database server is a domain member. Now...
0
by: Jarod_24 | last post by:
How does tabindex work in ASP .net pages I dosen't seem to work quite like in regular forms. and there isn't any TabStop property either. 1 .How do you prevent a control form beign "tabbed"....
14
by: Anoop | last post by:
Hi, I am new to this newsgroup and need help in the following questions. 1. I am workin' on a GUI application. Does C# provides Layout Managers the way Java does to design GUI? I know that it...
89
by: Cuthbert | last post by:
After compiling the source code with gcc v.4.1.1, I got a warning message: "/tmp/ccixzSIL.o: In function 'main';ex.c: (.text+0x9a): warning: the 'gets' function is dangerous and should not be...
14
by: webEater | last post by:
I have a problem, it's not browser specific, and I don't get a solution. I have an (X)HTML document, I show you a part of it: .... <!--<div class="pad">--> <div id="eventImages"><img src=""...
1
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post by:
I get the above error in some of the ASP.NET web applications on a server, and I need some help figuring out how to deal with it. This is a rather long post, and I hope I have enough details that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.