Guest User

Untitled

a guest
Nov 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #ifndef PLAYER_H_INCLUDED
  2. #define PLAYER_H_INCLUDED
  3. typedef struct Pocao{
  4. int codigo;
  5. }POCAO;
  6.  
  7. typedef struct inventario{
  8. int tamanho;
  9. POCAO*pocoes;
  10. }INVENTARIO;
  11.  
  12. typedef struct personagem{
  13. char*classe;
  14. INVENTARIO*inventario;
  15. }PERSONAGEM;
  16.  
  17. typedef struct player{
  18. char* nome;
  19. PERSONAGEM*personagem;
  20. }PLAYER;
  21.  
  22.  
  23. POCAO* Cria_Pocao();
  24. PERSONAGEM*Cria_Personagem();
  25. INVENTARIO *Cria_Inventario();
  26. PLAYER*Cria_Player();
  27.  
  28.  
  29.  
  30.  
  31.  
  32. #endif // PLAYER_H_INCLUDED
  33.  
  34. #include<stdio.h>
  35. #include<stdlib.h>
  36. #include"Player.h"
  37. PLAYER*Cria_Player()
  38. {
  39. Cria_Personagem();
  40. return (PLAYER*)malloc(sizeof(PLAYER));
  41. }
  42.  
  43. PERSONAGEM*Cria_Personagem()
  44. {
  45. Cria_Inventario();
  46. return (PERSONAGEM*)malloc(sizeof(PERSONAGEM));
  47. }
  48. INVENTARIO*Cria_Inventario()
  49. {
  50. Cria_Pocao();
  51. return (INVENTARIO*)malloc(sizeof(INVENTARIO));
  52. }
  53. POCAO*Cria_Pocao()
  54. {
  55. return(POCAO*)malloc(sizeof(POCAO));
  56. }
  57.  
  58. #include <stdio.h>
  59. #include <stdlib.h>
  60. #include"Player.h"
  61.  
  62.  
  63. int main()
  64. {
  65. FILE*arquivo;
  66. PLAYER*lista;
  67. int i;
  68. lista=(PLAYER*)malloc(sizeof(PLAYER)*6);
  69. for(i=0;i<6;i++)
  70. {
  71. lista[i]=Cria_Player();
  72.  
  73. }
  74.  
  75.  
  76. printf("Hello world!n");
  77. return 0;
  78. }
Add Comment
Please, Sign In to add comment