#include <stdio.h>
#include <stdlib.h>
#define DIM 4
typedef struct stackT{
int stack_array[DIM];
int head;
};
void init(struct stackT *pila);
int push(struct stackT *pila, int elem);
int pop(struct stackT *pila, int *elem);
int sizee(struct stackT *pila);
int is_emptyy(struct stackT *pila);
int main()
{
typedef struct stackT p;
char s;
int a;
int b;
init(&p);
printf("continui [s\n]");
scanf(&s);
do{
printf("inserisci a");
scanf(&a);
printf("%d, sizee(&p)");
if(push(&p, a)==1)
{
printf("la pila è piena");
s='n';
}
}while(s=='s');
int is_emptyy(&p);
printf("cancellare? [s\n]");
scanf(&s);
do{
printf("inserisci a");
scanf(&a);
if(pop(&p, &b)==1)
{
printf("la pila è vuota");
s='n';
}
printf("%d, b");
}while(s=='s');
int is_emptyy(&p);
return 0;
}
void init(struct stackT *pila){
pila->head=0;
return;
}
int push(struct stackT *pila, int elem){
if(pila->head==DIM)
return 1;
pila->stack_array[pila->head]=elem;
pila->head++;
return 0;
}
int pop(struct stackT *pila, int *elem){
if(pila->head==0)
return 1;
elem=pila->stack_array[pila->head];
pila->head--;
return 0;
}
int sizee(struct stackT *pila){
return pila->head;
}
int is_emptyy(struct stackT *pila){
if(pila->head==0)
return 1;
return 0;
}
||=== Build: Debug in struttura pila (compiler: GNU GCC Compiler) ===|
C:\Users\Simone\Desktop\codeblocks es\struttura pila\main.c|7|warning: useless storage class specifier in empty declaration|
C:\Users\Simone\Desktop\codeblocks es\struttura pila\main.c||In function 'main':|
C:\Users\Simone\Desktop\codeblocks es\struttura pila\main.c|23|error: expected expression before 'p'|
C:\Users\Simone\Desktop\codeblocks es\struttura pila\main.c|28|warning: passing argument 1 of 'scanf' from incompatible pointer type|
C:\Program Files (x86)\CodeBlocks\MinGW\include\stdio.h|347|note: expected 'const char *' but argument is of type 'int *'|
C:\Users\Simone\Desktop\codeblocks es\struttura pila\main.c|29|warning: format '%d' expects a matching 'int' argument [-Wformat=]|
C:\Users\Simone\Desktop\codeblocks es\struttura pila\main.c|30|error: expected expression before 'p'|
C:\Users\Simone\Desktop\codeblocks es\struttura pila\main.c|30|error: too few arguments to function 'push'|
C:\Users\Simone\Desktop\codeblocks es\struttura pila\main.c|11|note: declared here|
C:\Users\Simone\Desktop\codeblocks es\struttura pila\main.c|36|error: expected declaration specifiers or '...' before '&' token|
C:\Users\Simone\Desktop\codeblocks es\struttura pila\main.c|42|warning: passing argument 1 of 'scanf' from incompatible pointer type|
C:\Program Files (x86)\CodeBlocks\MinGW\include\stdio.h|347|note: expected 'const char *' but argument is of type 'int *'|
C:\Users\Simone\Desktop\codeblocks es\struttura pila\main.c|43|error: expected expression before 'p'|
C:\Users\Simone\Desktop\codeblocks es\struttura pila\main.c|43|error: too few arguments to function 'pop'|
C:\Users\Simone\Desktop\codeblocks es\struttura pila\main.c|12|note: declared here|
C:\Users\Simone\Desktop\codeblocks es\struttura pila\main.c|48|warning: format '%d' expects a matching 'int' argument [-Wformat=]|
C:\Users\Simone\Desktop\codeblocks es\struttura pila\main.c|50|error: expected expression before 'p'|
C:\Users\Simone\Desktop\codeblocks es\struttura pila\main.c|22|warning: unused variable 'b' [-Wunused-variable]|
C:\Users\Simone\Desktop\codeblocks es\struttura pila\main.c||In function 'pop':|
C:\Users\Simone\Desktop\codeblocks es\struttura pila\main.c|74|warning: assignment makes pointer from integer without a cast|
||=== Build failed: 7 error(s), 7 warning(s) (0 minute(s), 0 second(s)) ===|
riuscite ad aiutarmi per favore?