Author Topic: {C++} basic tutorial (part 1) "Hello World"  (Read 2038 times)

0 Members and 1 Guest are viewing this topic.

[TKC]Symantic

  • The Indifferent Character
  • The Central Committee
  • Heckler
  • *
  • Posts: 1647
  • I can has personal text?
    • View Profile
{C++} basic tutorial (part 1) "Hello World"
« on: December 30, 2008, 12:07:23 pm »
OK, so I'm sitting here bored with nothing else to do, this is for those of you who wish to create your first C++ application.

the first program anyone learns to write is called "Hello world", this consists of printing the text "Hello world" to the screen in a console.

OK, for people who are using windows based operating systems i suggest you get a C++ compiler called bloodshed Dev C++, don't fuss with fancy things like visual studio and such.

a compiler will link and compile your code into a language the machine can understand and in windows you will create a .exe file that will run your program.

-STEPS-
1)so lets get started, in bloodshed create a new console application, name it whatever.
2)bloodshed will set up your basic console application, it will include <iostream> which is your Input/Output stream class (sending input from another source EX. keyboard, and the output is where your sending it to, in this case it will be the screen.) don't worry about the rest yet. all you need to know is that in this example the input will be what we write in the code, and the output will be onto the screen.
3)you should have something similar to (I'm going off strictly memory here)
Code: [Select]
#include <cstdlib>
#include <iostream>

using namespace std;

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

ok, main is going to be loaded first (its the only thing we have right now) anything between the { and the } is your main function. we will get into functions later.

we are going to use cout (this is an output to the screen command).

double carrots specifies which way the information is going, and anything between quotes is thought of as a string.
so
Code: [Select]
cout<<"Hello World";
this is saying send the string Hello World to the screen.

the finished code will look something like this.

Code: [Select]
#include <cstdlib>
#include <iostream>

using namespace std;

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

tell me if it compiles lol.

-Symantic
« Last Edit: January 09, 2009, 12:53:35 am by [TKC]Symantic »
Enjoy your creative game-play, whatever that may include.

b00n

  • Insane Joker
  • ****
  • Posts: 608
  • pb,hackshield,vac sucks
    • View Profile
Re: {C++} basic tutorial (part 1) "Hello World"
« Reply #1 on: January 08, 2009, 12:34:34 am »
well, i have to post to see it xD

and i'm interrested :)


Berger

  • Online Villain
  • ***
  • Posts: 208
  • strdfu :)
    • View Profile
Re: {C++} basic tutorial (part 1) "Hello World"
« Reply #2 on: January 08, 2009, 12:31:51 pm »
well, i have to post to see it xD

and i'm interrested :)

indeed!

Jimmy

  • Insane Joker
  • ****
  • Posts: 618
    • View Profile
    • http://www.jimmyschot.com
Re: {C++} basic tutorial (part 1) "Hello World"
« Reply #3 on: January 08, 2009, 03:51:33 pm »
I have really no interest in C++, but I am a curious bastard.

[TKC]Lasher

  • Heckler Apprentice
  • ****
  • Posts: 1394
  • IWHBYD
    • View Profile
    • http://www.tkc-community.net
Re: {C++} basic tutorial (part 1) "Hello World"
« Reply #4 on: January 09, 2009, 06:54:33 am »
I get this when I start Bloodshed and it's not letting me compile



Whenever work feels overwhelming, just remember that you are going to die.

[TKC]Symantic

  • The Indifferent Character
  • The Central Committee
  • Heckler
  • *
  • Posts: 1647
  • I can has personal text?
    • View Profile
Re: {C++} basic tutorial (part 1) "Hello World"
« Reply #5 on: January 09, 2009, 07:56:12 am »
I get this when I start Bloodshed and it's not letting me compile




try uninstalling and deleting the files and then reinstalling it from a fresh download. my bet is you just downloaded the .exe or something from the site.

dont just download the .exe get the large file thing that includes gnu in it.
Enjoy your creative game-play, whatever that may include.

[TKC]Lasher

  • Heckler Apprentice
  • ****
  • Posts: 1394
  • IWHBYD
    • View Profile
    • http://www.tkc-community.net
Re: {C++} basic tutorial (part 1) "Hello World"
« Reply #6 on: January 09, 2009, 08:52:35 am »
Cool, thanks! What other things can you do with this?

Ah, I see it now
« Last Edit: January 09, 2009, 08:58:08 am by [TKC]Lasher »
Whenever work feels overwhelming, just remember that you are going to die.

cairney

  • Relentless Teamkiller
  • **
  • Posts: 58
  • There's no certainty ? only opportunity.
    • View Profile
Re: {C++} basic tutorial (part 1) "Hello World"
« Reply #7 on: July 08, 2009, 06:12:01 pm »
It worked like a charm for me

Leban

  • Poptart
  • *
  • Posts: 3
    • View Profile
Re: {C++} basic tutorial (part 1) "Hello World"
« Reply #8 on: October 02, 2014, 04:51:58 pm »
Nice Toturial btw :D