Follow us on Twitter!
You cannot teach a man anything; you can only help him find it within himself. - Galileo
Friday, April 25, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 26
Guests Online: 26
Members Online: 0

Registered Members: 82908
Newest Member: krishna7799
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

Help with C++


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 17-04-09 18:51
I am using a book to learn C++. I have noticed that every time that a program is displayed in the book the first lines are:

#include <cstdio>
#include <cstdlib>
#include < iostream>
using namespace std;

what do these lines mean?

also,

how do you know at what point it is allowed to take a function (a chunk of code)?




Edited by on 17-04-09 19:13
Author

RE: Help with C++


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 17-04-09 19:21
tuchezviper wrote:
I am using a book to learn C++. I have noticed that every time that a program is displayed in the book the first lines are:

#include <cstdio>
#include <cstdlib>
#include < iostream>
using namespace std;

what do these lines mean?

The first 3 are including the header files: http://en.wikiped. . .eader_file
And the last one is a namespace: http://www.cplusp. . .amespaces/
Try Google next time.

Edited by on 17-04-09 19:26
Author

RE: Help with C++


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 17-04-09 19:26
Just out of curiosity, what book do you use to learn c++. Because if it doesn't explain that, it must not be a good book ?
Author

RE: Help with C++

ynori7
Member



Posts: 1486
Location: #valhalla
Joined: 08.10.07
Rank:
God
Posted on 17-04-09 20:08
tuchezviper wrote:
#include <cstdio>
#include <cstdlib>
#include < iostream>
using namespace std;

what do these lines mean?

The first two, I'm not entirely sure why they need to be included, but they are:
cstdio = standard input-output from C
cstdlib = standard library of functions from C

The third is the input-output stream which allows you to reference functions for that purpose.

C++ has various namespaces which are groups of functions, identifiers, etc. "using namespace std" just specifies that you are using the std (standard) namespace.
If you didn't specify that, then for things such as outputting with cout, you would have to type std::cout instead. It basically tells the program to treat all names from the standard library like they were declared within the program.


how do you know at what point it is allowed to take a function (a chunk of code)?

What do you mean?


halls-of-valhalla.org/images/affiliateLogo.png voodoorage.halls-of-valhalla.org/images/smallLogo.png
i537.photobucket.com/albums/ff338/ynori77/archenemysig1.jpg
ynori7 http://halls-of-valhalla.org
Author

RE: Help with C++


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 17-04-09 20:08
inferior wrote:
Just out of curiosity, what book do you use to learn c++. Because if it doesn't explain that, it must not be a good book ?

Not necessarily, it might be a beginner's book or something similar that prioritizes teaching the basics of variables, input, output, operators, string manipulation, etc. first. This is actually not a bad technique since then one learns the syntax and functionality of what you can do with the simple basic things first and leave the underlying parts, which you won't really get into at the beginning anyway, to later.
If the book is a purely beginner's book it might therefor not contain it at all, or alternately contain it later on, but since they don't clearly say "headers" anywhere the person wouldn't know which chapter to look it up at.

tuchezviper wrote:
how do you know at what point it is allowed to take a function (a chunk of code)?

No idea what you meant by that, clarify.


Author

RE: Help with C++

p4plus2
Member

Your avatar

Posts: 167
Location:
Joined: 31.03.08
Rank:
Newbie
Posted on 17-04-09 23:44
tuchezviper wrote:
how do you know at what point it is allowed to take a function (a chunk of code)?

I think he means when do you know you can actually put code? If this is the question then you can place variables in the global scope(just after the area that we see the includes and namespace). For the logic segment of you program it must go in your main function which is set up like this:

Code

int main(int argc, char **argv){
//code here
}





You can also make a custom function but, you always need a main function.


Try to rephrase the question for a better answer.


"You can't be something your not,
Be yourself by yourself
Stay away from me" ~Walk, Pantera

"Playing an acoustic guitar is like having sex with your clothes on" ~Dave Mustaine
p4plus2@hotmail.com