Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 2nd, 2012  |  syntax: None  |  size: 0.66 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Passing structure as pointer
  2. #include <stdio.h>
  3. #include <stdbool.h>
  4. #include <string.h>
  5.  
  6. typedef struct {
  7.     int yearOfManufacture;
  8.     char model[50];
  9.     bool gasoline;
  10. } Car;
  11.  
  12.  
  13. void PrintCarDetails(Car details);
  14.  
  15. int main (int argc, const char * argv[])
  16. {        
  17.     Car ford;
  18.     ford.yearOfManufacture = 1997;
  19.     ford.gasoline = true;
  20.     strcpy(ford.model, "Focus");
  21.  
  22.     PrintCarDetails(&ford);
  23.  
  24.      return 0;
  25. }
  26.  
  27. void PrintCarDetails(Car *details)
  28. {
  29.     printf("Car model %s", details->model);
  30. }
  31.        
  32. void PrintCarDetails(Car * details);
  33.        
  34. void PrintCarDetails(Car *details);
  35.        
  36. void PrintCarDetails(Car *details);
  37.        
  38. void PrintCarDetails(Car *details);