FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
C++ PROGRAMMIN' r u any good?
Goto page 1, 2, 3  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    The Ville.org Half-Life Gaming Community Forum Index -> General Ramblings
View previous topic :: View next topic  
Author Message
South-American Fire Ant
Registered User


Joined: 25 Feb 2002

Posts: 26

PostPosted: Mon May 06, 2002 2:28 pm    Post subject: C++ PROGRAMMIN' r u any good? Reply with quote

#include <iostream.h>
int main()
{
int SomeVariable = 5;
cout << "SomeVariable: " << SomeVariable << "\n";

int *pVar = & SomeVariable;

int pVar = 9;
cout << "SomeVariable: " << *pVar << "\n";


return 0;
}


does anyone know whats wrong with this code?
i'm in HS and i suck at C++.

j0r phiaer anth,
m3
Back to top
View user's profile Send private message AIM Address
Kjeldorian Royal Guard 42
Registered User


Joined: 30 Nov 2001
Location: Dripping Springs, TX
Posts: 5563

PostPosted: Mon May 06, 2002 2:37 pm    Post subject: Reply with quote

You left out 4.



Or was it 8?


hmmmm....Oh yeah, I have no idea what you are talking about!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
YourPowersAreWeakOldMan
Registered User


Joined: 20 Aug 2001
Location: Houston Texas USA
Posts: 1745

PostPosted: Mon May 06, 2002 2:40 pm    Post subject: Reply with quote

Hey man, I only do other people's homework for cash $$.
_________________
World of Warcraft:
Bleeding Hollow PVP Server as Mortibund (undead mage)
Back to top
View user's profile Send private message
three_gunn
Registered User


Joined: 04 May 2002
Location: Hawthorne, CA
Posts: 424

PostPosted: Mon May 06, 2002 2:46 pm    Post subject: Reply with quote

YourPowersAreWeakOldMan wrote:
Hey man, I only do other people's homework for cash $$.



yeah!...now give me your lunch money, South-American Fire Ant!!

j/k man...im just jealous that you know C++ and youre still in highschool...back in my day...my school only had 'Power PC' macintosh used for typing classes
Back to top
View user's profile Send private message Send e-mail AIM Address
Snaggletooth
Guest





PostPosted: Mon May 06, 2002 2:49 pm    Post subject: Re: C++ PROGRAMMIN' r u any good? Reply with quote

South-American Fire Ant wrote:


int pVar = 9;
cout << "SomeVariable: " << *pVar << "\n";


It's been a while since I did any C++, but I think you want this

Code:
int pVar = 9;


to look like this

Code:
int *pVar = 9;


or maybe like this

Code:
pVar = 9;


Don't blame me if it compiles wrong again.... I'm rusty....and I don't do other people's homework unless they're a girl, and hot. Or they're gonna pay me lots of $$$$


Last edited by Snaggletooth on Mon May 06, 2002 3:21 pm; edited 1 time in total
Back to top
5th GHG E.G. Mine
Registered User


Joined: 02 Jan 2002
Location: Transcending 1337.
Posts: 1426

PostPosted: Mon May 06, 2002 3:10 pm    Post subject: Reply with quote

I'd help you if I could but C++ is next year for me.
_________________
http://www.chronixradio.com
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
FingerDemon
Registered User


Joined: 24 Aug 2001
Location: Virginia
Posts: 551

PostPosted: Mon May 06, 2002 3:14 pm    Post subject: Reply with quote

Fire Ant,

Also, I think you are declaring that variable twice. I don't program in C++, so maybe that's something you can do with pointers or something. But generally you declare the variable once like

int whatever = 0;

But then to assign it a value, you just go

whatever = 20,000,000;

You don't need to repeat the "int" every time.

Good luck, it might suck to be working on this now, but someday you'll hate something else WAAY more than this. Hmmm.... Ok, that probably didn't make you feel any better, so I'll stop now.

<TVB>FingerDemon-VS

P.S. And three gunn, I still remember my Dad going out to buy one of the first handheld calculators sold commercially. The thing was about the size of a brick, no kidding. And teachers in my school were of the firm opinion that no machine would ever replace the mimeograph, that modern marvel.
Back to top
View user's profile Send private message Send e-mail
three_gunn
Registered User


Joined: 04 May 2002
Location: Hawthorne, CA
Posts: 424

PostPosted: Mon May 06, 2002 3:28 pm    Post subject: Reply with quote

FingerDemon wrote:
P.S. And three gunn, I still remember my Dad going out to buy one of the first handheld calculators sold commercially. The thing was about the size of a brick, no kidding. And teachers in my school were of the firm opinion that no machine would ever replace the mimeograph, that modern marvel.



hahahahh....thanks fingerdemon...you don't know how much i needed that...
Back to top
View user's profile Send private message Send e-mail AIM Address
Dahak
Registered User


Joined: 10 Feb 2002
Location: Rochester, NY and Windsor, CT
Posts: 923

PostPosted: Mon May 06, 2002 3:38 pm    Post subject: Reply with quote

java > c++
Back to top
View user's profile Send private message
Lin Sivvi Defiant Hero
Registered User


Joined: 17 Jan 2002
Location: Some small boring city
Posts: 1205

PostPosted: Mon May 06, 2002 3:40 pm    Post subject: Reply with quote

[start really n00b like question]
What does the * character in front of a variable do/
[/end really n00b like question]

Code:
#include <iostream.h>

int main()
{
int SomeVariable = 5;
cout << "SomeVariable: " << SomeVariable << "\n";

int *pVar = & SomeVariable;

*pVar = 9;
cout << "SomeVariable: " << *pVar << "\n";


return 0;
}


I used that and compiled it... It's slightly different, but not by much. Also, what is the
Code:
int *pVar = & SomeVariable;

for? I took it out before and just left int *pVar =9; and it compiled fine.

Then again this is coming from a ten year old kid who doesn't know the answer to the above question
Back to top
View user's profile Send private message Send e-mail AIM Address
Computer
Registered User


Joined: 15 Feb 2002
Location: Dah A T L
Posts: 1336

PostPosted: Mon May 06, 2002 3:43 pm    Post subject: Reply with quote

It would help if you posted the errors also, I'll help ya if I can.
_________________
"Don't be so humble - you are not that great."
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Lin Sivvi Defiant Hero
Registered User


Joined: 17 Jan 2002
Location: Some small boring city
Posts: 1205

PostPosted: Mon May 06, 2002 3:47 pm    Post subject: Reply with quote

It says when I compile his code:

Quote:
C:\homework\main.cpp(10) : error C2040: 'pVar' : 'int' differs in levels of indirection from 'int *'


So the code I had above basiclly just adds the *, and takes out the second int., fixing the problem.
Back to top
View user's profile Send private message Send e-mail AIM Address
BitterBeerFace
Registered User


Joined: 17 Jan 2002
Location: Mankato, MinneSNOWta
Posts: 1416

PostPosted: Mon May 06, 2002 4:17 pm    Post subject: Reply with quote

Yes, you should only decalre int once, that's actually a command to initialize a vairable of "integer" type. Everytime you have "int" before something, it'll try to make a variable with that name, if you do it twice, it'll choke on compile.

First off, it'd be nice to know what the code is supposed to do.

It's been forever since I did any C++, but I think if you're just doing a little code to make a variable, and have it display the value of the variable, it'd be this:

#include <iostream.h>
int main()
{
int SomeVariable = 5;
cout << "SomeVariable: " << SomeVariable <<;
return 0;
}

That'd display "SomeVariable: 5"

Now then, if you're doing it to allow you to manipulate the variable by entering a value from the keyboard, you'll have to use the "cin >>" command to get a value from the keyboard.

I won't do the code for that, but hopefully that'll help ya get on the right track
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
Enrico
Registered User


Joined: 06 Jan 2002

Posts: 137

PostPosted: Mon May 06, 2002 5:03 pm    Post subject: Reply with quote

Hehehe, I dont do any C++ but i do fill my time with programming the TI-83 calculators. In my free time (school) i have made such classics as "GUESSNUM", and "DANCE", and let us not forget "MOOKA" hehehe, they use a psuedo basic language, right now i am working on "CIRCULAR"
My best program has about 150 lines and gets about 1fps...
Back to top
View user's profile Send private message
Lin Sivvi Defiant Hero
Registered User


Joined: 17 Jan 2002
Location: Some small boring city
Posts: 1205

PostPosted: Mon May 06, 2002 5:08 pm    Post subject: Reply with quote

lol! I program on the ti-83 too! I don't make complex stuff, but I make programs that solve stuff for me, I'm lazy Those calculators can handle assembly, I never bothered to learn it, but the assembly games are really neat.

Btw: I really don't know what the * in the variable name means, can someone tell me?

Well, this is enough of me carrying this post off topic, I gotta shutup
Back to top
View user's profile Send private message Send e-mail AIM Address
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    The Ville.org Half-Life Gaming Community Forum Index -> General Ramblings All times are GMT - 6 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group