> ~ Online tutorial

 struct (keyword)

 Groups variables into a single record

 Syntax:

  struct [<struct type name>] {
    [<type> <variable-name[, variable-name, ...]>] ;
    [<type> <variable-name[, variable-name, ...]>] ;
    ...
  } [<structure variables>] ;

A struct, like a union, groups variables into a single record.
             


Though both <struct type name> and <structure variables> are optional, one
of the two must appear.

Elements in the record are defined by naming a <type>, followed by one or
more <variable-name> (separated by commas).

Different variable types can be separated by a semicolon.

 Example:

  struct my_struct {
    char name[80], phone_number[80];
    int  age, height;
  } my_friend;

This struct declares an array of records containing two strings (name and
phone_number) and two integers (age and height).

To access elements in a structure, you use a record selector (.). For
example,

  strcpy(my_friend.name,"Mr. Wizard");

Please Give Us Your 1 Minute In Sharing This Post!
Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Powered By: BloggerYard.Com

0 comments: