Puzzle T10

array of pointers to stuct bulb

Create an array of struct pointers

Create an array of pointers to struct Bulb. Allocate memory for some of the array elements and initialize them. Print out the array. Deallocate memory.

#include <stdio.h>
#include <stdlib.h>

struct Bulb
{
  int watts;
  int lumens;
};

/* function to print a Bulb */
void printBulb( struct Bulb *b )
{
 printf("watts = %d\tlumens = %d\n", b->watts, b->lumens );
}

int main()
{
  /* declare and initialize an array of Bulb pointers */

  /* allocate memory for selected elements of the array */

  /* print the array */

  /* deallocate memory for the Bulb */
  
  return 0;
} 


Previous Page        Answer         Next Page         Home