Page 1 of 5
learning C++
Posted: Mon Jun 05, 2006 10:16 am
by fishfin
I've already downloaded a file that is suposed to help me do C++ on windows but after that I got stuck. Is there anyone who knows C++ who could give me some advice on how to start off? (I've tryed some of those online guides but when I coppy and past what they have this thing about compiling comes up and then after I do that I click run and nothing happens.)
Posted: Mon Jun 05, 2006 10:30 am
by fishfin
I just tryed a guide that explained what comiling is, this one is the best one I've found so far
http://www.cprogramming.com/tutorial/lesson1.html.
Posted: Mon Jun 05, 2006 10:53 am
by KVZ
Good luck

C++ is somewhat complicated language. Tried even some basic (Visual for example) first? Well, I will at one day start to learn assembly language of Intel x86 family

Posted: Mon Jun 05, 2006 11:22 am
by Gender
Fishfin, what kind of compiler have you got? I can help you, but maybe by means of PM?
Re: learning C++
Posted: Mon Jun 05, 2006 12:23 pm
by N-Aldwitch
fishfin wrote:I've already downloaded a file that is suposed to help me do C++ on windows but after that I got stuck. Is there anyone who knows C++ who could give me some advice on how to start off? (I've tryed some of those online guides but when I coppy and past what they have this thing about compiling comes up and then after I do that I click run and nothing happens.)
I'll be very happy to help you.
Two things though.
1) Have you programmed in anything else before, besides HTML?
2) Post the code here and I'll debug it for you.

Posted: Mon Jun 05, 2006 12:30 pm
by N-Aldwitch
Alright,
On the website it suggests to write this:
#include <iostream>
using namespace std;
int main()
{
cout<<"HEY, you, I'm alive! Oh, and Hello World!\n";
cin.get();
}
However my suggestion for this would be:
Code: Select all
#include <iostream>
int main()
{
std::cout << "Hello world!";
return 0;
}
And with comments about commenting things out and an extra line and /n
Code: Select all
#include <iostream>
int main()
{
/* this is a c-style comment
and it extends until the closing
star-slash comment mark */
std::cout << "Hello world!\n";
// this C++ -style comment ends at the end of the line
std::cout << "That comment ended!";
// double slash comments can be alone on a line
/* as can slash-star comments */
return 0;
}
Hope this helps.
Posted: Mon Jun 05, 2006 1:00 pm
by fishfin
I'm using this compiler:
http://www.download.com/3001-2069_4-10498828.html
and the only other programing language that I know is (limited) html.
Posted: Mon Jun 05, 2006 3:19 pm
by Pie
.............. man i wish there was a blank stair face that i could use... cous the only one here is te

face or

one
Posted: Tue Jun 06, 2006 6:39 am
by Gender
So, how is it going anyway? Did you manage to run this piece of code?
Posted: Tue Jun 06, 2006 7:37 am
by N-Aldwitch
Gender wrote:So, how is it going anyway? Did you manage to run this piece of code?
What he said... Because in some cases, your compiler may be out of date or no good.
Can I suggest Borland?
In particular, C++BuilderX is a great program released by Borland..

Posted: Tue Jun 06, 2006 8:51 am
by SekoETC
I read my first tutorial in Finnish...
You could use
if it isn't supposed to return anything.
And
makes a query sort of a thing. But char type variables were really hard at first so needs to use only numbers for queries. Since if you put the wrong type of data into a variable, for example char to int, it crashes (or more likely creates an endless loop). Also the variables need to be listed in the beginning like int a, b, c=1; and so on.
Later I learned a thing that records keypresses, after that you can use also letter commands and arrow keys.
It's been a while since I've touched Borland...
Oh and if you see nothing, that's most likely because the program runs itself and closes, because you didn't include a break there.
Posted: Tue Jun 06, 2006 9:04 am
by Gender
N-Aldwitch wrote:In particular, C++BuilderX is a great program released by Borland..

I'm hardcore gcc fan.
I have had some Borland experience, but it was on some DOS Borland C++ 4.5, as far as I remember
I wonder, why fishfin did not post any kind of error or warning messages...
Posted: Tue Jun 06, 2006 9:28 am
by fishfin
the code given by the website worked but the code you gave didn't, C++Builder is no longer availible for download (acording to a Google search)
and what did someone say up there about recording the keys pressed? How do you do that?
Posted: Tue Jun 06, 2006 10:01 am
by Gender
To pause the program execution you can for example wait for user to press a key on the keyboard.
Something like: "press any key to continue..."
If you don't include any statement, that will stop your program for a while, it will blink on your screen for a second, and you will not be able to read the results.
You can pause your program by several different ways, for example:
cin >> x; // where x is some variable
This instruction will stop your program until the user enters a number or string and hits enter.
there are various functions (get(), getch() or getchar()) which will stop your program. These functions will not wait for user to press enter. You can find description of them in manual for your compiler.
Posted: Tue Jun 06, 2006 10:22 am
by SekoETC
I think I used getch();... I don't have Borland on this computer, nor any of the text adventures I tried to make but maybe I could dig them up.