learning C++

General chitchat, advertisements for other services, and other non-Cantr-related topics

Moderators: Public Relations Department, Players Department

User avatar
fishfin
Posts: 490
Joined: Mon Mar 20, 2006 12:38 pm
Location: Nanning, China

learning C++

Postby fishfin » Mon Jun 05, 2006 10:16 am

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.)
The following statement is not true.

The previous statement is not true.
User avatar
fishfin
Posts: 490
Joined: Mon Mar 20, 2006 12:38 pm
Location: Nanning, China

Postby fishfin » Mon Jun 05, 2006 10:30 am

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.
The following statement is not true.



The previous statement is not true.
User avatar
KVZ
Players Dept. Member
Posts: 5309
Joined: Sun Sep 28, 2003 7:04 am
Location: Vlotryan
Contact:

Postby KVZ » Mon Jun 05, 2006 10:53 am

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 :P
Corruption born inside. I'm part of dark side / A.F.K. / We'll steal your dreams and control your minds
https://twitter.com/DukeKVZ / http://www.futurerp.net/pages/link.php?id=24880
Gender
Posts: 208
Joined: Tue Mar 14, 2006 9:02 am

Postby Gender » Mon Jun 05, 2006 11:22 am

Fishfin, what kind of compiler have you got? I can help you, but maybe by means of PM?
User avatar
N-Aldwitch
Posts: 1771
Joined: Thu Mar 16, 2006 1:48 am
Contact:

Re: learning C++

Postby N-Aldwitch » Mon Jun 05, 2006 12:23 pm

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. :D
Nakranoth's "evil" character says:
"Thief! That's terrible! *shakes his head* That would hurt people's feeling if I did that."


http://www.sylorn.com - Free MMORPG in development.. need help.
User avatar
N-Aldwitch
Posts: 1771
Joined: Thu Mar 16, 2006 1:48 am
Contact:

Postby N-Aldwitch » Mon Jun 05, 2006 12:30 pm

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.
Nakranoth's "evil" character says:

"Thief! That's terrible! *shakes his head* That would hurt people's feeling if I did that."





http://www.sylorn.com - Free MMORPG in development.. need help.
User avatar
fishfin
Posts: 490
Joined: Mon Mar 20, 2006 12:38 pm
Location: Nanning, China

Postby fishfin » Mon Jun 05, 2006 1:00 pm

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.
The following statement is not true.



The previous statement is not true.
User avatar
Pie
Posts: 3256
Joined: Sun Jun 19, 2005 3:30 am
Location: the headquarters of P.I.E.

Postby Pie » Mon Jun 05, 2006 3:19 pm

.............. man i wish there was a blank stair face that i could use... cous the only one here is te :?: face or :| one
Pnumerical Intuitiong Engyn
Paranormal Investigation Exorsism
Porcupine Interspecies Extra_poison
Pick In Enter

... The headquarters of P.I.E.!!!
Gender
Posts: 208
Joined: Tue Mar 14, 2006 9:02 am

Postby Gender » Tue Jun 06, 2006 6:39 am

So, how is it going anyway? Did you manage to run this piece of code?
User avatar
N-Aldwitch
Posts: 1771
Joined: Thu Mar 16, 2006 1:48 am
Contact:

Postby N-Aldwitch » Tue Jun 06, 2006 7:37 am

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..
:D
Nakranoth's "evil" character says:

"Thief! That's terrible! *shakes his head* That would hurt people's feeling if I did that."





http://www.sylorn.com - Free MMORPG in development.. need help.
User avatar
SekoETC
Posts: 15525
Joined: Wed May 05, 2004 11:07 am
Location: Finland
Contact:

Postby SekoETC » Tue Jun 06, 2006 8:51 am

I read my first tutorial in Finnish...

You could use

Code: Select all

void main()
{
//Something here
}


if it isn't supposed to return anything.

And

Code: Select all

cin >> variable_name;


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.
Not-so-sad panda
Gender
Posts: 208
Joined: Tue Mar 14, 2006 9:02 am

Postby Gender » Tue Jun 06, 2006 9:04 am

N-Aldwitch wrote:In particular, C++BuilderX is a great program released by Borland..
:D


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...
User avatar
fishfin
Posts: 490
Joined: Mon Mar 20, 2006 12:38 pm
Location: Nanning, China

Postby fishfin » Tue Jun 06, 2006 9:28 am

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?
The following statement is not true.



The previous statement is not true.
Gender
Posts: 208
Joined: Tue Mar 14, 2006 9:02 am

Postby Gender » Tue Jun 06, 2006 10:01 am

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.
User avatar
SekoETC
Posts: 15525
Joined: Wed May 05, 2004 11:07 am
Location: Finland
Contact:

Postby SekoETC » Tue Jun 06, 2006 10:22 am

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.
Not-so-sad panda

Return to “Non-Cantr-Related Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest