The C Language Revision - II

 

||     LOGIC FAMILIES     ||     C TUTORIAL I     ||     C TUTORIAL II     ||     RESUME     ||

 

This is more of my brain dump which I would be using to refer back myself, and, has nothing to do with the original text or ideas of K&R. I am not selling this. And it may contain errors/bugs. You may treat it as a reference or a tutorial or whatever.

The Famous Pointers

  • p = &c; p contains address of c, thus, p points to c.

  • *p returns what the variable c contains.

  • f (char *); is a function "f" whose argument is a pointer to char.

  • p = &a; q = &b; p = q; now p points to b.

  • f (a); pass by value.

  • f (&a); pass by pointers; pass by reference.

  • p = &a[0]; *(p + i) gives the value of the i th element in a[].

  • p = &a[0]; is same as p = a;

  • a[i] is same as *(a + i)

  • char b[]; is same as char *b;

  • alloc(n), returns a pointer p to n consecutive character positions. Similarly, malloc(n)

  • afree(p), releases the storage. Similarly, free(p)

  • C guarantees that 0 is never a valid address for data.

  • int (*a)[10] : a is an integer pointer to an array with 10 elements.

  • int *a[10] :  a is an array of 10 pointers to integers.

  • f ( int a[10][20] ) = is eqv. to = f ( int a[][20] ) = is eqv. to = f ( int (*a)[20] )

 

The lines of K&R

  • A structure is a collection of one or more variables, possibly of different types, grouped together under a single name for convenient handling.

  • A union is a variable that may hold (at different times) objects of different types and sizes (in the single area of storage), with the compiler keeping track of size and alignment requirements.

 

<< Previous <<


 

[email protected]

Content Copyright (c) 1998-2003
 Jagmeet Singh Hanspal.
All Rights Reserved.

Hosted by www.Geocities.ws

1