[Tutorial] Your first program

Posts 1–11 of 11 · Page 1 of 1
[Tutorial] Your first program
Btw sorry if this tutorial is hard to understand its my first
Create a new console Application (win32 is the same as a console application)

If the following Code is not in your Starting code already then put it in

#include <stdlib.h>
#include <iostream.h>
#include <string>
using namespace std;

int main(int main(int argc, char *argv[]))

{
system("PAUSE");
return 0;
}


Ok now go to the first Bracket and hit enter twice to start a line under the bracket.

then Type the following

cout << "hello i am your computer talking" << endl;

Now your code should look like this

#include <stdlib.h>
#include <iostream.h>
#include <string>
using namespace std;

int main(int main(int argc, char *argv[]))

{

cout << "hello i am your computer talking" << endl;

system("PAUSE");
return 0;

}


Now all you have to do is Build and compile then run it and a dos window should appear saying

"Hello , I am your computer talking"



Summary :

the command 'cout' tells the computer that you want to output some data through the console.

The 2 less than sign following the cout tell the computer that the thing that follows will be shown on the console.

The double quotes are to tell the computer where the string will start and end.

And Endl; means that you want to start a new line.



Hope this helped Some of you soon-to-be programmers on your way of learning, I will Be making a tutorial soon on how to make the console add,substract,multiply or divide numbers.

-Dan
where can i get a free c/c++ compiler that isnt dev-c++? it doesnt work for me...
Quote Originally Posted by Skurdz View Post
where can i get a free c/c++ compiler that isnt dev-c++? it doesnt work for me...
Why isnt dev-c++ working for you? I think its a great ide. I use it as well. But you can try cygwin. Its also free.
hamm ... dont really get what this dose.. i only se a cout and it says im your cumputer talking nothing more really :S
All this for a simple "Hello Worl!" I don't think so...
Quote Originally Posted by SpiderByte
All this for a simple "Hello Worl!" I don't think so...
lolz good stuff
You don't need all of that in there honestly, all you really need is a simple cout output message and then you can get it to say something. And you don't have to include those libraries just include the iostream.

Something easy like

Code:
#include <iostream>
using namespace std;

int main() {
    cout << "Hello World";
    return 0;
}
That's as easy as it gets.. but I don't know why you did all of that extra stuff just to make it say something you don't really need to put all of that, lol.

And that's using C++.. :/

Course if you want to start in C you can, but I think C++ is somewhat easier, don't ask me why I thikn this but seriously, not everyone is right about starting with C.
I replaced "hi, I'm your computer talking." with "hi, I am your ass-slave"
Quote Originally Posted by EkstatikX
I replaced "hi, I'm your computer talking." with "hi, I am your ass-slave"
Fun is what programming is all about right?
Ok.....so I can use c++ to map out a prog like the Headshot single kill for warrock?
#include <stdlib.h>
#include <iostream.h>
#include <string>
using namespace std;

int main(int main(int argc, char *argv[]))

{

cout << "hello i am your computer talking" << endl;

system("PAUSE");
return 0;

}

thats C/not C++ (this is C++ Section)

C#/C++ would be more like

#include <iostream>
using namespace std;
int main()
{
cout<<"Eny text";
cin.get(); //if you want
Posts 1–11 of 11 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?