• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 08:22
CEST 14:22
KST 21:22
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
BGE Stara Zagora 2025: Info & Preview25Code S RO12 Preview: GuMiho, Bunny, SHIN, ByuN3The Memories We Share - Facing the Final(?) GSL46Code S RO12 Preview: Cure, Zoun, Solar, Creator4[ASL19] Finals Preview: Daunting Task30
Community News
[BSL20] ProLeague: Bracket Stage & Dates7GSL Ro4 and Finals moved to Sunday June 15th12Weekly Cups (May 27-June 1): ByuN goes back-to-back0EWC 2025 Regional Qualifier Results26Code S RO12 Results + RO8 Groups (2025 Season 2)3
StarCraft 2
General
The SCII GOAT: A statistical Evaluation Magnus Carlsen and Fabi review Clem's chess game. BGE Stara Zagora 2025: Info & Preview Jim claims he and Firefly were involved in match-fixing GSL Ro4 and Finals moved to Sunday June 15th
Tourneys
Bellum Gens Elite: Stara Zagora 2025 Master Swan Open (Global Bronze-Master 2) $5,100+ SEL Season 2 Championship (SC: Evo) SOOPer7s Showmatches 2025 Cheeseadelphia 2025 - Open Bracket LAN!
Strategy
[G] Darkgrid Layout Simple Questions Simple Answers [G] PvT Cheese: 13 Gate Proxy Robo
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 476 Charnel House Mutation # 475 Hard Target Mutation # 474 Futile Resistance Mutation # 473 Cold is the Void
Brood War
General
Will foreigners ever be able to challenge Koreans? BGH auto balance -> http://bghmmr.eu/ BW General Discussion I made an ASL quiz [BSL20] ProLeague: Bracket Stage & Dates
Tourneys
[ASL19] Grand Finals [Megathread] Daily Proleagues [BSL20] ProLeague Bracket Stage - Day 2 [BSL20] ProLeague Bracket Stage - Day 1
Strategy
I am doing this better than progamers do. [G] How to get started on ladder as a new Z player
Other Games
General Games
What do you want from future RTS games? Path of Exile Stormgate/Frost Giant Megathread Nintendo Switch Thread Mechabellum
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
LiquidLegends to reintegrate into TL.net
Heroes of the Storm
Heroes of the Storm 2.0 Simple Questions, Simple Answers
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Vape Nation Thread European Politico-economics QA Mega-thread
Fan Clubs
Maru Fan Club Serral Fan Club
Media & Entertainment
Korean Music Discussion [Manga] One Piece
Sports
2024 - 2025 Football Thread Formula 1 Discussion NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread Cleaning My Mechanical Keyboard
TL Community
The Automated Ban List
Blogs
Cognitive styles x game perf…
TrAiDoS
StarCraft improvement
iopq
Heero Yuy & the Tax…
KrillinFromwales
I was completely wrong ab…
jameswatts
Need Your Help/Advice
Glider
Trip to the Zoo
micronesia
Poker
Nebuchad
Customize Sidebar...

Website Feedback

Closed Threads



Active: 25648 users

C++ for dummies question

Blogs > {CC}StealthBlue
Post a Reply
{CC}StealthBlue
Profile Blog Joined January 2003
United States41117 Posts
May 31 2009 18:20 GMT
#1
So I downloaded Dev-C++ from the net but is an further updated version in the book and the new project is different that the one being shown in the book, at the start.
http://search.barnesandnoble.com/C-All-in-One-Desk-Reference-for-Dummies/Jeff-Cogswell/e/9780764517952/?itm=2


#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
system("PAUSE");
return EXIT_SUCCESS;
}


^Is showing when I create a new project but in the book the figure is showing this:

#include <iostream>
#include <stdlib.h>

int main(int argc, char *argv[])
{
system("PAUSE");
return 0;
}


Is this going to cause trouble or even affect the step by step tutorials in the book?

*****
"Smokey, this is not 'Nam, this is bowling. There are rules."
VIB
Profile Blog Joined November 2007
Brazil3567 Posts
May 31 2009 18:29 GMT
#2
It could be since you'd call the std library differently. So it would depend on what the book does. But it could eventually become a problem. I would just comment out the namespace line to be safe and go by the book.

But are you aware that devcpp is an abandoned project that isn't updated since 2005? So if your book has an even older version, it must be really really old :p
Great people talk about ideas. Average people talk about things. Small people talk about other people.
Cambium
Profile Blog Joined June 2004
United States16368 Posts
May 31 2009 18:32 GMT
#3
It's been about five years since I did C++, but they look the same to me.

iirc, stdlib.h and cstdlib refer to the same thing, and I think the namespace is declared within the header file.

Also, EXIT_SUCCESS is just a global variable that's defined in cstdlib.

Your book should probably explain these things.
When you want something, all the universe conspires in helping you to achieve it.
Grobyc
Profile Blog Joined June 2008
Canada18410 Posts
Last Edited: 2009-05-31 18:48:23
May 31 2009 18:39 GMT
#4
It doesn't look like you need the line
#include <iostream>

Because you aren't inputting or outputting anything.

As for the
return 0;

That ends the program, yes.

EDIT: Oh if you are actually putting more stuff in the program you will need the
#include <iostream>

still.

You should probably still include
using namespace std;

Because that's what I use in programming and the version I have uses
return 0;

There's no harm anyway.
If you watch Godzilla backwards it's about a benevolent lizard who helps rebuild a city and then moonwalks into the ocean.
Random()
Profile Blog Joined August 2004
Kyrgyz Republic1462 Posts
May 31 2009 18:42 GMT
#5
"using namespace" literally means that you are, well, going to use that name space.

The point is that you may have several classes or functions that have same names, but reside in
different namespaces which allows to differentiate between them.

e.g.

namespace A {
class X;
}

namespace B {
class X;
}

Then, when you want to refer to a particular class X from one of the namespaces, you use A::X or B::X. This functionality is mostly used by libraries to avoid name clashes with other libraries while still allowing to have good class names, for example "Vector" instead of "libXYZ_Vector".

However, if you are using only one library and don't expect any clashes, you state "using namespace X", and when resolving symbols (class/function names) the compiler would check not only the default namespace, but also namespace X. This allows not to write A::X each time that you want to use class X, but just X.

To answer your question directly, it will not make any difference unless you define a class or function with the exact same name as one of the classes/functions from the std library, which is unlikely.
Grobyc
Profile Blog Joined June 2008
Canada18410 Posts
Last Edited: 2009-05-31 18:53:11
May 31 2009 18:52 GMT
#6
There's no harm in including unused declarations anyway. What I would just put to be safe is
#include <cstdlib>
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(int argc, char *argv[])
{
system("PAUSE");
return 0;
}
If you watch Godzilla backwards it's about a benevolent lizard who helps rebuild a city and then moonwalks into the ocean.
cgrinker
Profile Blog Joined December 2007
United States3824 Posts
May 31 2009 19:00 GMT
#7
EXIT_Success is going to be 0, the idea being that there were no errors in exiting.
vAltyR
Profile Blog Joined July 2008
United States581 Posts
May 31 2009 19:01 GMT
#8
cstdlib and stdlib.h are the same thing. I've used them interchangably in my C++ class last semester.
내 호버크라프트는 장어로 가득 차 있어요
Osmoses
Profile Blog Joined October 2008
Sweden5302 Posts
May 31 2009 19:10 GMT
#9
The exit success thing is just a global variable. I'm more curious about why there are arguments in the main function. I've never had any, though admittedly it's been like...6-7 years since I did C++.
Excuse me hun, but what is your name? Vivian? I woke up next to you naked and, uh, did we, um?
b3h47pte
Profile Blog Joined May 2007
United States1317 Posts
May 31 2009 19:20 GMT
#10
you don't really need them there as far as i'm concerned but the IDE's like to put them there for some reason. maybe someone with more knowledge of the subject can expalin more?
araav
Profile Blog Joined September 2004
Armenia1590 Posts
May 31 2009 19:21 GMT
#11
ok, here is the thing (it's a little bit too technical, sorry, but if you want to know what's the deal, here is it).
C++ is based on C and it keeps backward compatibility with C as much as it is possible. C has these fancy libraries exposed through stdio.h, stdlib.h, stdarg.h, etc.

C++ (BS indeed) decided to make these include things to be abstracted from filesystems, etc, so the ".h" psotfix would not make sense right? that's why they changed all those NAMEs to cNAME, like cstdio, cstdarg, etc. now these files expose the old interfaces through the namespace std.

so
#include <stdio.h>

is completely equivalent to
#include <cstdio>
using namespace std;

The latter one is preferable, because it's C++, not C, and it's going to be always supported (though unlikely that the former one will ever be dropped). The C++ thing is preferable also because it does not pollute the global namespace with old C things. So the better way is to do

#include <cstdio>

and use
std::printf("%s", "I'm a good C++ fellow");


lol who asked me to jump in and write all this? :S

oh yeah, btw, cxxx files are mostly implemented like this:
// file cxxx
namespace std {
#include <xxx.h>
}; //namespace std

The flower that blooms in adversity is the most rare and beautiful of all.
jonnyp
Profile Blog Joined May 2009
United States415 Posts
Last Edited: 2009-05-31 19:26:56
May 31 2009 19:24 GMT
#12
yeah that is weird 0.o

as far as the cstdlib and stdlib.h, if i remember correctly in C you use the library stdlib.h but when you use C++ all the old c libraries were renamed as clibraryname. so stdlib.h became cstdlib, math.h became cmath etc. but i havent c++ed in a while so i might be off

edit: you beat me to it
The number of years it takes for the Internet to move past anything is way, way over 9000.
{CC}StealthBlue
Profile Blog Joined January 2003
United States41117 Posts
May 31 2009 19:36 GMT
#13
holy fuck error(s) when I changed it the way the book was =/

0 errors on this, maybe =/

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
cout << "Hello, I am your computer talking." << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
"Smokey, this is not 'Nam, this is bowling. There are rules."
R3condite
Profile Joined August 2008
Korea (South)1541 Posts
Last Edited: 2009-06-01 00:25:13
June 01 2009 00:24 GMT
#14
iono wat
using namespace std;
is but EXIT_SUCCESS is the same thing as returning 0 if i remember correctly... also all it does is turn on some flag saying that the method exited successfully which will keep a handler from catching some kind of error and throwing u an exception
ggyo...
{CC}StealthBlue
Profile Blog Joined January 2003
United States41117 Posts
June 01 2009 01:13 GMT
#15
Chapter 1 finished. 772 pages left to go.
"Smokey, this is not 'Nam, this is bowling. There are rules."
{CC}StealthBlue
Profile Blog Joined January 2003
United States41117 Posts
Last Edited: 2009-06-03 07:18:04
June 03 2009 07:17 GMT
#16
So there is no difference between, they are both the same thing correct?

system("PAUSE");
return 0;
}


and

system("PAUSE");
return EXIT_SUCCESS;
}


???
"Smokey, this is not 'Nam, this is bowling. There are rules."
EsX_Raptor
Profile Blog Joined February 2008
United States2801 Posts
June 03 2009 07:25 GMT
#17
On June 03 2009 16:17 {CC}StealthBlue wrote:
So there is no difference between, they are both the same thing correct?

Show nested quote +
system("PAUSE");
return 0;
}


and

Show nested quote +
system("PAUSE");
return EXIT_SUCCESS;
}


???

Do you understand what a function is right? main is a function with return value of type int. Whatever this value is, it won't change anything. It can be 0, 1, 2, ... it doesn't matter, however, using 0 is just a convention so as to say "The function returned successfully."

In the above example, EXIT_SUCCESS must be a global variable of type int whose value could be any number (most likely 0), so in the end, it's just the same thing.

I hope this helped.
araav
Profile Blog Joined September 2004
Armenia1590 Posts
June 03 2009 07:50 GMT
#18
#define EXIT_SUCCESS 0
#define EXIT_FAILURE 1

don't use those definitions, don't depend on stdlib.h. do return 0; instead
The flower that blooms in adversity is the most rare and beautiful of all.
DeathSpank
Profile Blog Joined February 2009
United States1029 Posts
June 03 2009 08:00 GMT
#19
On June 01 2009 03:20 {CC}StealthBlue wrote:
So I downloaded Dev-C++ from the net but is an further updated version in the book and the new project is different that the one being shown in the book, at the start.
http://search.barnesandnoble.com/C-All-in-One-Desk-Reference-for-Dummies/Jeff-Cogswell/e/9780764517952/?itm=2


Show nested quote +
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
system("PAUSE");
return EXIT_SUCCESS;
}


^Is showing when I create a new project but in the book the figure is showing this:

Show nested quote +
#include <iostream>
#include <stdlib.h>

int main(int argc, char *argv[])
{
system("PAUSE");
return 0;
}


Is this going to cause trouble or even affect the step by step tutorials in the book?

no. you'll learn letter about macros and const variables. EXIT_SUCCESS actually = 0
for learning purposes though go with return 0 unless you have other reasons not to.
yes.
Please log in or register to reply.
Live Events Refresh
SC Evo League
12:00
#13
BRAT_OK 37
LiquipediaDiscussion
Bellum Gens Elite
10:00
Stara Zagora 2025 Day 4
ShoWTimE vs SerralLIVE!
Clem vs Zoun
Bellum Gens Elite2911
ComeBackTV 1225
TaKeTV 546
IndyStarCraft 316
3DClanTV 152
Rex122
CosmosSc2 75
LiquipediaDiscussion
CranKy Ducklings
10:00
Master Swan Open #92
CranKy Ducklings104
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Bellum Gens Elite2911
IndyStarCraft 316
Hui .239
Rex 122
ProTech82
CosmosSc2 75
BRAT_OK 37
MindelVK 9
StarCraft: Brood War
Britney 36522
Calm 27953
Sea 4925
Bisu 2728
Jaedong 2302
Hyuk 987
Mini 316
BeSt 286
EffOrt 243
Last 218
[ Show more ]
Zeus 204
Soulkey 140
Stork 137
PianO 115
Mind 114
Hyun 91
ZerO 77
sorry 56
Sea.KH 40
Icarus 24
Sacsri 23
GoRush 21
Noble 11
SilentControl 9
IntoTheRainbow 8
ajuk12(nOOB) 8
Dota 2
qojqva1257
XcaliburYe711
League of Legends
KnowMe45
Heroes of the Storm
Khaldor263
Other Games
singsing2370
B2W.Neo1044
DeMusliM560
Mlord212
Mew2King186
Lowko182
Pyrionflax149
XaKoH 115
ZerO(Twitch)13
ArmadaUGS8
rubinoeu2
Organizations
Dota 2
PGL Dota 2 - Main Stream6468
StarCraft: Brood War
UltimateBattle 23
StarCraft 2
angryscii 19
StarCraft: Brood War
lovetv 8
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• Adnapsc2 20
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Michael_bg 4
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Nemesis5700
• Jankos1293
Upcoming Events
Fire Grow Cup
2h 38m
CSO Contender
4h 38m
BSL: ProLeague
5h 38m
StRyKeR vs MadiNho
Cross vs UltrA
TT1 vs JDConan
Bonyth vs Sziky
Replay Cast
11h 38m
SOOP Global
14h 38m
Creator vs Rogue
Cure vs Classic
SOOP
20h 38m
Classic vs GuMiho
Sparkling Tuna Cup
21h 38m
AllThingsProtoss
22h 38m
Fire Grow Cup
1d 2h
BSL: ProLeague
1d 5h
HBO vs Doodle
spx vs Tech
DragOn vs Hawk
Dewalt vs TerrOr
[ Show More ]
Replay Cast
1d 11h
Replay Cast
2 days
Replay Cast
2 days
WardiTV Invitational
2 days
WardiTV Invitational
2 days
GSL Code S
3 days
Rogue vs GuMiho
Maru vs Solar
Replay Cast
4 days
GSL Code S
4 days
herO vs TBD
Classic vs TBD
The PondCast
4 days
Replay Cast
5 days
GSL Code S
5 days
WardiTV Invitational
5 days
Korean StarCraft League
6 days
CranKy Ducklings
6 days
WardiTV Invitational
6 days
Liquipedia Results

Completed

CSL Season 17: Qualifier 1
DreamHack Dallas 2025
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
BSL Season 20
KCM Race Survival 2025 Season 2
NPSL S3
Rose Open S1
CSL Season 17: Qualifier 2
2025 GSL S2
BGE Stara Zagora 2025
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
ECL Season 49: Europe
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025
YaLLa Compass Qatar 2025
PGL Bucharest 2025
BLAST Open Spring 2025

Upcoming

CSL 17: 2025 SUMMER
Copa Latinoamericana 4
CSLPRO Last Chance 2025
CSLPRO Chat StarLAN 3
K-Championship
SEL Season 2 Championship
Esports World Cup 2025
HSC XXVII
Championship of Russia 2025
Murky Cup #2
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.