Joined: Mon 08-16-2004 10:40AM Posts: 1460 Location: \/ I hate these guys /\ (Altman 209)
Source: Altman Hall
Im new to C++ and Ive got a question, I dont know how to do it in C++, but how do i create a "sub" or "marker" that i can send the program to if certain things are true or input, such as
Quote:
person puts in a 1 for H
if H=1 goto "sub" something else goto "sub" somethingelse
sub something
code code code code code
sub somethingelse
code code code code code
I used the sub command when messing with Easy UO scripting but apparently its not the same in C++, is there a command like this or am I just having wishful thinking? I cant seem to find anything like it in the book and would appreciate any light that someone could shed on the situation... I know I dont have all the correct symbols in there but thats the basic idea of what I'm trying to do...
_________________ "Nuke 'em till they glow, then shoot 'em in the dark!"
Joined: Sun 08-18-2002 10:33AM Posts: 751 Location: Kansas City, KS
Source: TJ North
Functions? They don't have to take arguments or return anything:
Code:
void something() { // code goes here }
void somethingelse() { // more code }
void main() { int h = 1; if(h == 1) something(); else something(); // more code after something() or somethingelse() returns }
_________________ It is by caffeine alone I set my mind in motion.
It is by the beans of Java the thoughts acquire speed,
the hands acquire shaking, the shaking becomes a warning.
It is by caffeine alone I set my mind in motion.
Joined: Mon 08-16-2004 10:40AM Posts: 1460 Location: \/ I hate these guys /\ (Altman 209)
Source: Altman Hall
hmm thatll work for what I'm looking for, but is there a way to make it move to that part of the program and continue on instead of going to that function, doing it, then going back to the point it came from?
_________________ "Nuke 'em till they glow, then shoot 'em in the dark!"
you can put whatever code you want inside the fucntion to make it seem like its continuing on, but the way c++ works is to call a function to do something then return to the main function
Joined: Mon 08-16-2004 10:40AM Posts: 1460 Location: \/ I hate these guys /\ (Altman 209)
Source: Altman Hall
i got another one, i cant get my if-else statement to output a message
Quote:
if (t==H) cout << "Enter age (in calender years)\n"; else if (t==D) cout << "Enter age in Human years: \n";
i need it to output one of these statements depending on what the user inputs for t, and then i need to request a particular input depending also on what t==, but when i have it setup like above it wont display either of the cout statements if an approptiate choice it pushed in, it simply ignores them and goes on
_________________ "Nuke 'em till they glow, then shoot 'em in the dark!"
Joined: Sun 08-18-2002 10:33AM Posts: 751 Location: Kansas City, KS
Source: TJ North
Can you post the rest of your code? The snippit you gave is rather ambiguous.
_________________ It is by caffeine alone I set my mind in motion.
It is by the beans of Java the thoughts acquire speed,
the hands acquire shaking, the shaking becomes a warning.
It is by caffeine alone I set my mind in motion.
Joined: Tue 09-11-2001 2:34PM Posts: 1084 Location: Off Campus (i.e. not hell)
Source: VPN
Just by looking at it... if you are expecting the characters 'D' and 'H' you need to put the single quotes around them. If they're actually variables forget what I just said.
_________________ People with doctorate degrees get to be called Doctor. So yes, I guess I am your Master... bitch
Joined: Mon 08-16-2004 10:40AM Posts: 1460 Location: \/ I hate these guys /\ (Altman 209)
Source: Altman Hall
ahh ok, got that fixed, one last question, what do i punch in to make it "clear" everything after the program starts, so it wont have all my other junk above the actual program??
_________________ "Nuke 'em till they glow, then shoot 'em in the dark!"
Users browsing this forum: No registered users and 2 guests
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