Re: [Circle] SEMI-NEWBIE QUESTION: Circle Data types???

From: R. Seth Trotman (sfd@ix.netcom.com)
Date: 07/27/96


I think it's worth mentioning how powerful the cast operator can be.  And
the 
fact that it can be used for ANY data type.

Let's look at an example.

Let's say you've got 2 structures:
struct struct1 {
	char player_name[20];
	float score;
};

struct struct2 {
	char character_name[20];
	int strength;
	int wisdom;
}; 

Then, in your code, you can perform tests on pointers to memory by just
using the cast operator. 

...
  int wis;
  wis = ((struct struct2)ptr)->wisdom;
...

or something like that, anyway. 

----------
> From: Limratana <wlimrata@merlin.cc.manhattan.edu>
> To: Alex <fletcher@cspo.queensu.ca>; BUBONIC@CERES.BSUVC.BSU.EDU
> Cc: Circle <circle@cspo.queensu.ca>
> Subject: Re: [Circle] SEMI-NEWBIE QUESTION: Circle Data types???
> Date: Friday, July 26, 1996 10:28 PM
> 
> (int) is a cast operator.  What that means is that during a calculation,

> the variable after (int) is turned into an int for compatibility with
> whatever you are assigning the value to.  For instance, 
> int i;
> float k, l;
> 
> k= 1.2;
> l= 3.456;
> 
> i= (int) k * (int) l;
> or maybe you want 
> i = (int) (k * l);
> this ensures that a float doesn't end up being assigned to an integer 
> variable.  There might be other uses for (int) that I don't know about
too.
> 
> +-----------------------------------------------------------+
> | Ensure that you have read the CircleMUD Mailing List FAQ: |
> |   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
> +-----------------------------------------------------------+
+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/07/00 PST