This wiki is out of date, use the continuation of this wiki instead

Struct

From FenixWiki

Revision as of 23:25, 16 June 2007 by Sandman (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search


Contents

Definition

STRUCT

Structs are datatypes, able to contain variables of all datatypes.

To address a member of a struct, use the "." operator: <structname>.<membername>. Like all datatypes, one can have a whole range of them, as displayed in the example.

Example

Structs can be handy for many aspects of programming.

Multiple identical data groups

Struct Ship[9]
    int x;
    int y;
    int speed;
    int angle;
End

There are 10 'Ship's now. The data can be accessed like:

Ship[0].speed++;
Ship[8].angle = 0;

Grouping of variables

This is for clarity and to avoid colliding variable names.

Struct Fileinfo
    String name;
    String path;
End

Note that the struct fileinfo is a predefined global variable.

Personal tools