Structures  symoff datatype

Chapter 1: Overview

Structure declaration

The format for a structure declaration is:

struct tag 
{
structure members;
}
variable names;

where tag is a user selected name, structure members are data members accessed by variables declared as this structure type, and variable names are the names of the variable declared as this type of structure.

NoteYou must separate multiple variable names with a comma.

Table 1-15: Structure declaration formats

Format

Description

tag variable_name;

Declares a variable as this type.

variable_name.data_member =value;

Assigns a value to a data member.

Examples

Structural declaration:

struct sample {int test;string name;blob date_time;}

Variable declaration:

struct sample sm1, sm2;

Assigning values:

sm1.test = 100;
sm2.test = 500;

NoteDo not assign one structure variable to another. For example, sm2 = sm1 is invalid. However, you may assign individual elements; thus, sm2.test = sm1.test is valid.





Copyright © 2005. Sybase Inc. All rights reserved. symoff datatype

View this book as PDF