Alguien que sepa cual es el error en este programa en DEV-C++

Iniciado por Shannon, 27 Septiembre 2018, 23:30 PM

0 Miembros y 1 Visitante están viendo este tema.

Shannon

Código (cpp) [Seleccionar]
#include <stdio.h>
#include<stdlib.h>


typedef struct nodo_s
{
char dato;
struct nodo_s *siguiente;
} nodo_t;

typedef nodo_t *ptrNodo;
typedef nodo_t *ptrPila;

void push (ptrPila *pila, char x)
{
ptrNodo nodo;
nodo = (ptrNodo)malloc(sizeof(nodo_t));
if (nodo !=NULL)
{
nodo->dato = x;
nodo->siguiente =*pila;
*pila=nodo;

}
}

char pop(ptrPila *pila)
{
ptrNodo nodo;
char x;

nodo =*pila;
x = (*pila)->dato;
*pila = (*pila)->siguiente;
free(nodo);
return x;
}
int pila_vacia(ptrPila *pila)
{
return(*pila == NULL ? 1:0);

}
void nodos_pila(ptrNodo nodo)
{
if(nodo==NULL)
printf("la pila está vacia\n");
else
{
while (nodo !=NULL)
             {
printf("%c\n",nodo->dato);    
nodo = nodo->siguiente;
}
printf("\n");
}
}


His name will live, brother
No, I got-, I feel hella shitty because it's like, I '
Like, if I would have known it was so cool
And it's like, I ', if I would have watched interviews sooner, bro', we were so alike
It's unfortunate because it's like, me, when people die, that's when you're there, you know?
'Cause your remorse kinda makes you check' em out

OmarHack

I like to test things.

Shannon

me da este error que no se porque
18  undefined reference to `WinMain'
      [Error] ld returned 1 exit status
His name will live, brother
No, I got-, I feel hella shitty because it's like, I '
Like, if I would have known it was so cool
And it's like, I ', if I would have watched interviews sooner, bro', we were so alike
It's unfortunate because it's like, me, when people die, that's when you're there, you know?
'Cause your remorse kinda makes you check' em out

OmarHack

Claro que te da ese error. No hay función main en el programa.
Qué es exactamente lo que quieres hacer? xD
I like to test things.

Shannon

His name will live, brother
No, I got-, I feel hella shitty because it's like, I '
Like, if I would have known it was so cool
And it's like, I ', if I would have watched interviews sooner, bro', we were so alike
It's unfortunate because it's like, me, when people die, that's when you're there, you know?
'Cause your remorse kinda makes you check' em out

OmarHack

I like to test things.

Shannon

implementar  las funciones push y pop para ser utilizadas con caracteres

His name will live, brother
No, I got-, I feel hella shitty because it's like, I '
Like, if I would have known it was so cool
And it's like, I ', if I would have watched interviews sooner, bro', we were so alike
It's unfortunate because it's like, me, when people die, that's when you're there, you know?
'Cause your remorse kinda makes you check' em out

OmarHack

Lo estás mirando en clase, o aprendiendo por tu cuenta?
I like to test things.

Shannon

#8
en clase


como pongo un main y un constructor aqui?


//INTENTE HACERLO ASI PERO ME MARCA 0. ALGUIEN QUE SEPA COMO HACERLO?
Código (cpp) [Seleccionar]
#include<stdio.h>
#include<stdlib.h>

typedef struct nodo_s
{
char dato;
struct nodo_s *siguiente;
} nodo_t;

typedef nodo_t * ptrNodo;
typedef nodo_t * ptrPila;

void push (ptrPila *pila, char x)
{
ptrNodo nodo;
nodo = (ptrNodo)malloc(sizeof(nodo_t));
if (nodo!= NULL)

{
nodo->dato = x;
nodo->siguiente = *pila;
*pila=nodo;

}
}

char pop (ptrPila *pila)
{
ptrNodo nodo;
char x;

nodo = *pila;
x = (*pila)->dato;
(*pila)->siguiente;

free(nodo);
return x;
}
int pila_vacia(ptrPila *pila)
{
return (*pila == NULL ? 1:0);
}

void nodos_pila(ptrNodo nodo)
{
if(nodo == NULL)
printf("La pila esta vacia \n");
else
{
while (nodo!= NULL)
{
printf("%c\n");

nodo = nodo->siguiente;
}
printf("\n");
}
}
main()
{
ptrPila pila = NULL;
push(&pila,43);
push(&pila,95);
push(&pila,20);
if ( !pila_vacia(&pila)){

printf("\n ESTOS SON LOS NUMEROS DE LA PILA: \n");
nodos_pila(pila);
}

}



ALGUIEN!!! :-( :-( :-(

MOD: No hacer múltiples posts. Usa el botón modificar. . Usa etiquetas GeShi.
His name will live, brother
No, I got-, I feel hella shitty because it's like, I '
Like, if I would have known it was so cool
And it's like, I ', if I would have watched interviews sooner, bro', we were so alike
It's unfortunate because it's like, me, when people die, that's when you're there, you know?
'Cause your remorse kinda makes you check' em out

CalgaryCorpus

El printf no imprime nada ahora, pues no recibe argumentos.
Sugiero poner un valor o variable para que se imprima algo.
Aqui mi perfil en LinkedIn, invitame un cafe aqui