//Test one using C++ by Chef
//Lines beginning w/ # are directives for the preprocessor.
#include <iostream>
// Tells the preprocessor to include iostream standard file.
// iostream includes declarations of basic input-output library
using namespace std;
//namespace std(standard) is the entity in which we are writing code.
int main ()
// beginning of the main function, start of execution, all C++
// programs must have a main function, makes this function #1
{
//cout functions requires iostream. This is a statement line.
cout<<"Hello World!";
//semicolon is the end of a statement in C++.
//Most common syntax error is not using semicolon.
return 0;
//return statement causes main function to finish.
}
//cout is the standard output stream in C++.
//cout is always declared in the iostream standard file within the
//std namespace.
//The code above has the same functions as the one below, just written differently.
#include <iostream> using namespace std; int main () {cout<<"Hello People!"; cout <<"Testing 1 2 3!"; return 0;}
#include <iostream>
using namespace std; int main () {cout<<"Hello People!"; cout <<"Testing 1 2 3!"; return 0;}
The last one, #include <iostream> has to have it's own line.#include <iostream>
using namespace std; int main () {cout<<"Hello People!"; cout <<"Testing 1 2 3!"; return 0;}
Code can be posted in a [ code=Cpp] tag (remove the space).
I don't hope you are going to use Evilzone as a diary and post your progress everyday?
- lol, you have made a Hello, World! in C++ there's not much to explain about that. Otherwise what dense wrote.
No I'm not going to use EZ as a diary. I just want to, since its my start, ask y'all make sure I'm doing it correctly. I'll only have questions as I go along.
Fixed OP's post.
Why not? I think its great. Probably useful for others learning C++.
Use EZ as your diary if you like. Maybe not EVERY day tho. Depends how much work you put into each day I guess. :)
Pretty much what I was gonna do. lol
I'm pretty damn hooked on this C++ right now. I wish I was at home, I downloaded Microsoft Visual Studios last night which is pretty awesome. 30 day trial though. :( Any others out there I could use in replace of MS?I haven't downloaded a compiler either yet!
Staff note: Please dont double post.
(http://www.cplusplus.com/doc/tutorial/variables/scope_of_variables.gif)
The global variables are the variables you "declared to be those variables", right?
And awesome, I will download that tonight!
And what? Did I double post?
#include <iostream>
using namespace std;
int globalVariable;
void myFunction(){
int localVariable=34;
globalVariable++; //or globalVariable = globalVariable+1;
}
int myFunct(){
int var = 34;
return var;
}
int main(){
globalVariable = 0;
cout << "Global variable = " << globalVariable << endl; // will print 0
myFunction();
cout << "Global variable = " <<globalVariable << endl; //will print 1
cout << " Local variable = " << localVariable << endl; //you will get a warning of undifined variable, will print out trash that is at that memory address
int localVar = myFunct();
cout << "LocalVar = " << localVar << endl; // will print 34
return 0;
}
//strings can be written w/ out an initial value but given one
// during execution.
#include <iostream>
#include <strings>
using namespace std;
int main ()
{
string mystring;
mystring = "This is my no value string.";
cout << mystring <<endl;
mystring = "My string now has a value.";
cout << mystring << endl;
return 0;
}
Okay so I just got introduced to strings from the tutorial.
//strings can be written w/ out an initial value but given one
// during execution.
#include <iostream>
#include <strings>
using namespace std;
int main ()
{
string mystring;
mystring = "This is my no value string.";
cout << mystring <<endl;
mystring = "My string now has a value.";
cout << mystring << endl;
return 0;
}
When starting a string that has no value but gets a value during execution why does it start w/ "string mystring;"?
Why does the string end w/ "cout << mystring << endl;"? What is "endl;"?
Thanks guys.
string mystring = "This is my string";
cout << "Hello" << endl << "World";
mystring = "this is a string with a newline escape\n" ;
a = 5; |
//Introduction to strings in C++
#include <iostream> //the basic input/output library for C++
#include <string> //the library to be able to use strings
using namespace std; //this is the entity in which we are writing code
int main ()
{
string mystring = "Hello World!"; //string is the variable and mystring is the variable identifier
cout << mystring; //cout is the basic statement line commonly used in C++
return 0; //return 0; tells the computer the code is over
}[code]
L"This is a wide character string" |
//Below we will be defining constants \
this feature is handy when it comes to memory-consuming \
variables like 3.14159
#include <iostream>
#include <string>
#define PI 3.14159 //#define is a directive for the preprocessor
#define NEWLINE '\n'
using namespace std;
int main ()
{
double r=5.0; //this is the radius
double circle;
circle = 2 * PI * r;
cout << circle;
cout << NEWLINE;
return 0;
}
If double is so much more precise shouldn't I just always use it over float?
Sure, but it's more expensive in terms of memory.
Not just memory, but math involving it too can impact speed and performance. Imagine games using math involving nth places when rendering a vertex matrix of a map, you would get like 5fps. In programming it is up to the coder to decide appropriate datatypes.
I would advise you dive straight into using cstrings or char arrays.Roger that. I just got introduced to string streams last night...
Experience tells me cstrings are something you will see a large amount of in any C / C++ environment.
Personally I strongly prefer them to strings. Try both out and see which you like more~
Experience tells me cstrings are something you will see a large amount of in any C / C++ environment.
Personally I strongly prefer them to strings. Try both out and see which you like more~
In my experience that isn't true but it probably varies a lot. C++ code will almost entirely use C++ strings and then use c_str() to convert when necessary, C code will of course, use C strings.So in C++ there are C strings and C++ strings? Oh lord, this is gonna be a pain to learn.
"like" is not a good judge here. C++ strings are *always* better than C Strings (char* and char[]). You can always convert from a C++ string to a C string if you need to (or want to....) but C++ strings have so much more useful features like size(), substr(), insert(), including auto managing memory of the buffer for you, something you would have to manually do with C strings (malloc and realloc is a pain!).
Oh lord, this is gonna be a pain to learn.
Use EZ as your diary if you like. Maybe not EVERY day tho. Depends how much work you put into each day I guess. :)
Whoa, what? I say keep going strong with c++. All that language changing and anxiety only makes you weaker.
Yes, it will. And not even in a "trial by fire" sort of way. C++ is a language designed to be used by a team of professional developers per project. Judging from your earlier posts, you're a beginner to programming. Do yourself a favor and start with something simpler. I'd suggest going with pure C first, as waspxor hinted at. From there, you can move to C++ if you wanted to. No time wasted.
I do want to eventually get into hacking, white hat and black hat. I want to have a vast knowledge around it all. After learning C, my route will head where?
Well, wherever you want it to go. There are a ton of different programming concepts you can use and apply to hacking/cracking/etc. If you're interested in programming malware, you could look into socket programming in order to create client/server applications that communicate over the internet. That way, if you can get one of the ends on the victim's computer, they can communicate and you can program it to do whatever you want. You could also learn about hardware hooks, to use a keyboard hook to code a keylogger and email you back the logs. You could learn about HTTP libraries in order to gather information from websites. There's so many different ways to approach it.
Yeah I know there are so many different ways to approach it! It's causing me to feel lost on what to do!
I need guidance! Lol
Yeah I know there are so many different ways to approach it! It's causing me to feel lost on what to do!
I need guidance! Lol
When you say website im going to assume you really did mean website and not server stuff.
If your trying to attack a website, learn how to create one first. For that you will need to know at least php/sql and html, but also some javascript could help. C++ has little place there afiak but im probably wrong, since some of those languages are built on c++. But it would likely be pointless and overly complicated to use c++ for it.
And I am interested in server stuff as well. I mean I don't want any stone unturned. Basically my outlet into the hacking world is through all these ebooks I downloaded. There are quite a bit of them but I don't mind the time investment in reading them.
What i do know you can use c++ to do as far as hacking websites go are things like vulnerability scanners, page phishing, ddos, and other tools. But not usually for direct hacking, i dont think. You need to know web languages for that.
If you do intend to learn those, some common vulnerabilities you might want to search include: sqli, lfi/rfi, csrf, and xss. However, any code can be exploited more easily when you actually understand how it potentially works.
Also, i think you need to learn the art of sticking to one thing at a time. Stick with c++ and dont worry about web programming languages, unless that's really what you intended to do in the first place. At most, use c++ to create tools like I wrote above.