MMOwned - World of Warcraft Exploits, Hacks, Bots and Guides

Homepage Register FAQ Members Mark Forums Read Advertise Marketplace FPSowned


Go Back   MMOwned - World of Warcraft Exploits, Hacks, Bots and Guides > WoW Emulator Server > Emulator Server Guides
Reload this Page [N00b tips] C++ guide
Emulator Server Guides Guides for working with World of Warcraft Emulator servers. Learn how to create a WoW Server here.
[NO QUESTIONS HERE]

Reply
 
LinkBack Thread Tools
[N00b tips] C++ guide
(#1)
Old
EviNion's Avatar
EviNion is Offline
Sergeant
Rep Power: 1
Reputation: 9
EviNion is an unknown quantity at this point
 
Posts: 57
Join Date: Jul 2008
Location: In teh Shad0wz
[N00b tips] C++ guide - 07-07-2008

Getting Started:

By the end of this tutorial you would have learnt how to output text,

Intro:
I've always been sort of dissapointed with RaGEZONE's Coders section. It's always been full of VB-wh0res and web developers (although, WDs aren't bad). I've always wanted RaGEZONE's coders section to become more Desktop-programming orientated (Not inc VB). Although I think only 5-10% of this section consists of this.
So I'm here to provide people with a series of C++ tutorials (How many, is depending on the comments I recive: Good/Bad).
So here's Lesson #1:

The first you're going to need to begin your C++ adventure is a descent compiler. There are many compilers about... some of which, barely pass as a compiler.

Although there are many C/C++ compilers about, there are two in mind that are considered the best (better userability/more user-friendly, better compiler and better debugger).
Personally I'd say Microsoft's Visual C++ Compiler and IDE has a better debugger, I feel Bloodshed's Dev-C++ IDE and Compiler is more user-friendly, and easier to navigate.
But don't take my word for it, try it out for yourself:


(Windows Compatible)
Microsoft Visual C++:
Overview: Download details: Visual C++ 2005 Redistributable Package (x86)
Download: [Only registered and activated users can see links. ]

(Windows Compatible) (Reccomended)
Bloodshed's Dev-C++:
Overview: Bloodshed Software - Dev-C++
Download: SourceForge.net: Downloading ...

Other: (Reccomended by Daevius)
Code :: Blocks:
Download: SourceForge.net: Downloading ...

Okay, so I'm going to be writing a tutorial as if you were using Dev-C++ v5.0, although if you have any other version of Dev-C++ or even a different compiler, the simple things like Compile and Run are pretty much simple.

So, lesson #1 is going to be teaching you how to compile your first program, and explaining data types.
So I'm going to need you to install the provided downloads given to you, install the programs and then double click the exe to launch the program.
So after you have launched the program, you're going to want to create a console application (the next few tutorials we will be using console application).
So go to File > New > Project... and then select Console Application, and name it 'MyProject' or anything you want (It's just a name), but it's best to keep a directory, for easy access and organisation. Once you've given a name to your project, make sure that 'C++ Project' is selected. Once you have done all of this, click 'Ok'.

Now, you should have a window with the following code in it:

Code:
#include <cstdlib>#include <iostream>using namespace std;int main(int argc, char *argv[]){ system("PAUSE"); return EXIT_SUCCESS;}

...or some similar code.

What I want you to do is highlight it all and delete, so your project is left empty.

Okay, so after that's done, I want you to take a look at this code:

Code:
#include <iostream>using namespace std; int main(){cout << "Hello There RaGEZONE\n"; // Outputs the sentence "Hello There RaGEZONE") cin.get(); // Requests user to hit Enter key to end application }
Anything familiar about the above code? If not, no worries at all This is the reason I'm here, to teach you what this means and how to use it

That's start with #include <iostream>.
#include <iostream> is something called a preprocessor directive that requests code from that header file to put into our application.
By including a header file, it provides you with the use of certain functions, such as cout.


The next line of code is: using namespace std;
using namespace std; is similar to that of <iostream>. Basically, this line of code is something called a standard library. Using this line, it allows you to use certain functions such as cout. (See the similarities?). Also, notice the semi-colon ( ; ) on the end of the the line of code. This is apart of C++'s syntax and is used for most commands.



Now the next line is int main ().
This is the beginning of the main functions. It's where the C++ program's start their execution (depending on the location of the code).
int is for when the fuction returns an integer.
The braces ( { } ) bascially defines the beginning and the end of the execution.
Everything after { is what will be executed, everything before } is what has been executed.

Note: When I say "Executed" it basically means performed/done/run.


cout << "Hello There RaGEZONE\n";
Now what this is doing is outputting the phrase "Hello There RaGEZONE"
Think of the statement cout as output.
cout is declared in the iostream standard file within the std namespace, this is the reason why we needed to include that specific file and to declare that we were going to use this specific namespace earlier in our code. (Every line of code is done for a reason). The bracket things << are insertion indicators, indicating what our output is going to be.
The \n means newline. What it does is seperate output on the screen, so it doesn't look disorganised:
Example:

Code:
cout << "Hello Ragezone";cout << "I'm Awesome";
This would output as:

Quote:
Originally Posted by Output
Hello RagezoneI'm Awesome

Now, if you wanted a space between Ragezone and I'm, you would have to make sure you left a space in one of them:

Code:
cout << "Hello Ragezone ";cout << "I'm Awesome";
or

Code:
cout << "Hello Ragezone";cout << " I'm Awesome";
Or if you wanted it to be one line of code:

Code:
cout << "Hello Ragezone\nI'm awesome";
Output:

Quote:
Originally Posted by Output
Hello Ragezone I'm awesome

Note: Notice how the \n (newline) is ALWAYS within the double quotation marks? This is a Must!

Note: C++ is a case-sensitive language, so everything has to be the way it's supposed to be:
Cout = wrong
cout = right

//
This is simply to mark line notes. They don't affect the application in anyway, they're only used for viewers of the code.
/* this is
a
blocknote*/
A blocknote is a... well, a note formatted as a block. This is used for full, descriptive explenations of a piece of code.

cin.get();
(Notice the ; ? It's been used throughout this application, remember what I said? It's used on functions).
Without placing the cin.get(); , the application window will instantaneously open and close. By placing cin.get(); at the end (before the end bracket), it means the application needs the user to press enter for the application to close.

After you have typed all of this code in, and know what everything is, try mesing about with the code a bit. Insert \n with new phrases. Learning C++ is all about exploring. I'm going to give you a guideline but you will have to explore solo a bit if you want to fully understand C++'s nature

And for the end part:
After you are happy with your codes, go to Execute > Compile & Run name it to whatever you want and there you have it! Your first C++ application.
This is the end of C++ Tutorial #1
I will be writing C++ Tutorial #2 Soon

What will be in Tutorial #2?:
You will be learning about data types, becoming more familiar with console applications and functions within. I will teach you how to use declare and define, how to manipulate integers and will result in teaching you on how to make a calculator

C&C Would be greatly appreciateed

Sincerely EviNion
Reply With Quote

Donate to remove ads.
(#2)
Old
arigity's Avatar
arigity is Offline
Knight-Champion
Rep Power: 1
Reputation: 30
arigity is on a distinguished road
 
Posts: 449
Join Date: Dec 2007
07-07-2008

should use moar whitespace on your code as this ->> #include <iostream>using namespace std; int main(){cout << "Hello There RaGEZONE\n"; // Outputs the sentence "Hello There RaGEZONE") cin.get(); // Requests user to hit Enter key to end application } looks really mashed and can have misleading comments.

|
v

#include <iostream>
using namespace std;
int main()
{
cout << "Hello There RaGEZONE\n";
// outputs the sentence "hello There RaGEZEONE")
cin.get(); // Requests user to hit Enter key to end application
}

all in all a nice guide though.


Reply With Quote
(#3)
Old
EviNion's Avatar
EviNion is Offline
Sergeant
Rep Power: 1
Reputation: 9
EviNion is an unknown quantity at this point
 
Posts: 57
Join Date: Jul 2008
Location: In teh Shad0wz
07-07-2008

ahh okay, thanks
Reply With Quote
(#4)
Old
mager1794's Avatar
mager1794 is Offline
Contributor
Rep Power: 1
Reputation: 125
mager1794 will become famous soon enoughmager1794 will become famous soon enough
 
Posts: 317
Join Date: Feb 2008
07-07-2008

this is a repost its on mmowned on one of the last few pages in the guide section


Reply With Quote
(#5)
Old
**Sweeny**'s Avatar
**Sweeny** is Offline
Knight-Lieutenant
Rep Power: 1
Reputation: 33
**Sweeny** is on a distinguished road
 
Posts: 284
Join Date: Dec 2007
07-08-2008

Quote:
What will be in Tutorial #2?:
The next page of the c++ tutorial website?? This is just using simple 5 lined scripts...


Reply With Quote
(#6)
Old
SectorSeven's Avatar
SectorSeven is Offline
Banned
Rep Power: 0
Reputation: 444
SectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really nice
 
Posts: 1,965
Join Date: Oct 2007
07-08-2008

Looks like more of a copy/paste master than C++
Reply With Quote
(#7)
Old
EviNion's Avatar
EviNion is Offline
Sergeant
Rep Power: 1
Reputation: 9
EviNion is an unknown quantity at this point
 
Posts: 57
Join Date: Jul 2008
Location: In teh Shad0wz
07-11-2008

Sad Face, you caught me:P

But I forgot to add

Guide: ' the maker's name'

So I am sorry =(

forgiveness pl0x

Thanks EviNion


"Although I May Be Wrong Here, I am Never Far From Right" - EviNion
Reply With Quote
Reply

Donate to remove ads.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On



Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vBulletin Skin developed by: vBStyles.com


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346