fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. //creating a struct for a data structure
  5.  
  6. struct Stack {
  7. int size;
  8. int (*Arr)[10];
  9. int top;
  10. };
  11.  
  12. //function prototype
  13. void print_Stack(struct Stack *pilha);
  14.  
  15. int main(void) {
  16. struct Stack pilha;
  17. int Elementos[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  18.  
  19. pilha.Arr = &Elementos;
  20. pilha.size = sizeof Elementos / sizeof (int);
  21.  
  22. print_Stack(&pilha);
  23. return 0;
  24. }
  25.  
  26. //creating a print stack function
  27. void print_Stack(struct Stack *pilha) {
  28. for (int x = 0; x < pilha->size; x++) {
  29. printf("[%d-", (*pilha->Arr)[x]);
  30. printf("%d] ", pilha->Arr[0][x]);
  31. }
  32. }
  33.  
Success #stdin #stdout 0s 5492KB
stdin
Standard input is empty
stdout
[1-1] [2-2] [3-3] [4-4] [5-5] [6-6] [7-7] [8-8] [9-9] [10-10]