Red de conocimiento informático - Computadora portátil - C empujar y hacer estallar

C empujar y hacer estallar

#include lt; stdio.hgt;

#include lt; malloc.hgt

#define max 10

estructura typedef

{

char a[max];

int top;

}qstype

void init(qstype *s)

{

s-gt; arriba =-1

}

int push(qstype *s, char x)

{

if (s-gt; top gt; = max)

{

devuelve 0;

else

{

s-gt; arriba

s-gt; a[s-gt; ;

Devuelve 1;

}

}

char pop(qstype *s)

{

if(s-gt; top lt; 0)

{

Devuelve 0; else

{

> return s-gt; a[s-gt; arriba];

s-gt;

}

}

impresión nula(qstype *s)

{

int i;

for(i=0;ilt;s-gt;top;i)

printf("c", s-gt;a[i]);

}

int main(void)

{

char ch;

qstype *A, *B;

A =(qstype *) malloc(sizeof(qstype));

B=(qstype *)malloc(sizeof(qstype)); //puntero no inicializado

init(A) ;

init(B);

scanf("c", amp; ch);;

while(ch!='\n')

{

if(push(A, ch) ==0)

break

scanf("c", amp; ch);

}

imprimir(A);

devolver 0;