www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/25/09:34:41

Message-ID: <363344B1.A0509DA1@montana.com>
Date: Sun, 25 Oct 1998 08:33:05 -0700
From: bowman <bowman AT montana DOT com>
X-Mailer: Mozilla 4.5b2 [en] (Win95; I)
X-Accept-Language: en
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: Another Newbie Question.. A Code that needs stream-lining..
References: <hKDY1.1817$sP DOT 7022 AT newsfeed DOT slurp DOT net>
Reply-To: djgpp AT delorie DOT com


Cuculain wrote:
> 
> Anyways, I think I got the right idea, however, as I posted before, I'm new
> to C/C++, and well, I'm not sure if I could use a portion of an array as a
> variable..

You really need to go back and fight your way through that book on C.
Try the
following snippet, (which i hope i cut 'n' pasted right this time).  If
you really
need a bunch of global Q values, you could use  int Q[6], and put the
line,

Q[i-1] = 1; 

in QuestValue. see your book for why its 'i-1', what '&' means, and just
what
'<<=' is doing.
 
void QuestValue(int value) {
		
	int mask = 1;
	int i;

	printf("value = %d\n", value);
	for (i=1; i<7; i++) {
		if (value & mask)
			printf("Quest %d completed\n", i);
		mask <<= 1;
	}
}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019