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).




0 comments:

Copyright

Copyright © 2008 C Tutorial, All rights are reserved