Showing posts with label Comparison of structure variables. Show all posts
Showing posts with label Comparison of structure variables. Show all posts

Saturday, May 10, 2008

Pointer(Arrays of Pointer )

Arrays of Pointer

We can have arrays of pointers since pointers are variables.

Example use: Sort lines of text of different length.

Note: Text can't be moved or compared in a single operation.

Arrays of Pointers are a data representation that will cope
efficiently and conveniently with variable length text lines.

How can we do this: Store lines end-to-end in one big char
array n will delimit lines.

Store pointers in a different array where each pointer
points to 1st char of each new line.

Compare two lines using strcmp () standard library function.

If 2 lines are out of order swap pointer in pointer array (not text).




Comparison of structure variables

Comparison of structure variables

Two variables of the same structure type can be compared
the same way as ordinary variables.


operation meaning

person1=person2*assign perosn2 to person1

person1== person2*compare all name of person1 and person2 and return1

Union(Accessing a union member )

Accessing a union member



To access a union member, you can use the same syntax
that you use for structure members.

Example:

code.m, code.x etc.

During execution, we should make sure that the value
of accessing member is currently stored.

Copyright

Copyright © 2008 C Tutorial, All rights are reserved