fork download
  1. #include<stdio.h>
  2. #define n 5
  3. struct stacks
  4. {
  5. int arr[n];
  6. int top;
  7. };
  8. struct stacks s;
  9. void create()
  10. {
  11. if(s.top==(n-1))
  12. {
  13. printf("the stacks is full");
  14. return;
  15. }
  16. int f;
  17. printf("enter stacks\n");
  18. scanf("%d",&f);
  19. if(n>=f)
  20. {
  21. for(int i=0;i<f;i++)
  22. {
  23. scanf("%d",&s.arr[i]);
  24. ++s.top;
  25. }}
  26. else
  27. printf("the stack is incresing thee size\n");
  28. }
  29. void display()
  30. {
  31. if(s.top==-1)
  32. {
  33. printf("the stack is empty");
  34. return;}
  35. else
  36. {
  37. for(int i=s.top;i>=0;i--)
  38. printf("%d\n",s.arr[i]);
  39. }
  40. printf("\n\n");
  41. }
  42. int main()
  43. {
  44. s.top=-1;
  45. create();
  46. display();
  47. printf("%d"s.top);
  48. return 0;
  49. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function 'main':
prog.c:47:13: error: expected ')' before 's'
  printf("%d"s.top);
             ^
prog.c:47:9: warning: format '%d' expects a matching 'int' argument [-Wformat=]
  printf("%d"s.top);
         ^
stdout
Standard output is empty