Advertisement
Madotsuki

Untitled

May 7th, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. // Here's the include blah, blah,
  2. // #define blah blah
  3.  
  4. // Before you write the functions and all that, you need to declare the existence of your custom data-type.
  5. // That's why you use typedef struct, as shown below.
  6.  
  7. typedef struct {
  8.     char name[10];
  9.     int level,
  10.         hp,
  11.         atk,
  12.         def,
  13.         spatk,
  14.         spdef,
  15.         spd;
  16. } pokemon;
  17.  
  18. // Here's how you would use it inside the code:
  19.  
  20. int main()
  21. {
  22.     // We can now have a custom datatype called Pokemon!
  23.     pokemon electabuzz;
  24.     // How do you access the elements inside it?
  25.     // Just add a period...
  26.     electabuzz.name = "Electabuzz";
  27.     electabuzz.level = 100;
  28.     // etc
  29.     // You can do various comparison factors with these...
  30.     // like say, if(electabuzz.level > psyduck.level) or something.
  31.     // It's like another way to name a variable.
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement