Dev - C++ - Tengo un error de return 1 exit status alguien me ayuda?

 
Vista:

Tengo un error de return 1 exit status alguien me ayuda?

Publicado por Ivan (4 intervenciones) el 14/03/2019 14:56:11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
 
typedef struct Nodo{
    char nombre[20];
    struct Nodo *anterior;
    struct Nodo *siguiente;
}Nodo;
Nodo *primero=NULL;
Nodo *ultimo=NULL;
    Nodo *aux, *nuevoNodo;
    int elemento;
    void agregar();
 
int main(){
 
	agregar("uno");
    agregar("dos");
    agregar("tres");
    agregar("cuatro");
    agregarEnPosicion("dos punto cinco",2);
    imprimir(1);
    imprimir(2);
 
	typedef Nodo head;
	int respuesta;
	int n;
 
	printf("¿Que desea hacer?(presione la tecla con la que desea la opcion)\n\n");
	printf("Eliminar nodo=1\n");
	printf("Agregar Posicion=2\n");
	printf("Convertir una lista a una cola=3\n");
	printf("Convertir una pila=4\n\n");
	scanf("%i",&respuesta);
 
	switch(respuesta){
		case 1:{
			printf("En que posicion quieres que elimine el nodo\n");
		scanf("%i",&n);
		while(elemento!=NULL){
			elemento++;
			aux->siguiente=nuevoNodo;
			nuevoNodo->siguiente=aux->siguiente;
			nuevoNodo->anterior=aux->anterior;
		}
			break;
		}
		case 2:{
		agregar();
			break;
		}
	}
	}
void agregar(){
	void agregar(char *val){
    Nodo *nuevoNodo;
    nuevoNodo=malloc(sizeof(Nodo));
    if(nuevoNodo!=NULL){
        strcpy(nuevoNodo->nombre,val);
    }
    else{
        printf("ERROR, NO HAY MEMORIA DISPONIBLE");
    }
    if(primero==NULL){
        primero=nuevoNodo;
        ultimo=nuevoNodo;
   	}else{
        nuevoNodo->anterior=ultimo;
        ultimo->siguiente=nuevoNodo;
        ultimo=nuevoNodo;
    	}
	}
}
void imprimir(int dir){
    Nodo *aux;
    aux=malloc(sizeof(Nodo));
    if(aux!=NULL && primero!=NULL){
        if (dir==1){
            aux=primero;
            while(aux!=NULL){
                printf("%s <-> ",aux->nombre);
                aux=aux->siguiente;
            }
            printf("\n");
        }
        if(dir==2){
            //completar recorrido inverso
            aux=ultimo;
            while(aux!=NULL){
                printf("%s <-> ",aux->nombre);
                aux=aux->anterior;
            }
            printf("\n");
        }
    }else{
        printf("ERROR LA LISTA NO TIENE ELEMENTOS O NO HAY MEMORIA SUFICIENTE");
    }
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 10
Ha aumentado 1 puesto en Dev - C++ (en relación al último mes)
Gráfica de Dev - C++

Tengo un error de return 1 exit status alguien me ayuda?

Publicado por Hector (7 intervenciones) el 14/03/2019 17:57:23
En el void debe ser algo así:

int imprimir(void)
return 1
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Tengo un error de return 1 exit status alguien me ayuda?

Publicado por Ivan (4 intervenciones) el 14/03/2019 19:12:58
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
typedef struct {
    char nombre[20];
    struct Nodo *anterior;
    struct Nodo *siguiente;
}Nodo;
 
Nodo *primero=NULL;
Nodo *ultimo =NULL;
 
void agregar(char *);
void agregarEnPosicion(char *, int pos);
int void imprimir(int dir);
 
void agregarEnPosicion(char *val, int pos){
    int posActual=1;
    Nodo *aux, *nuevoNodo;
    aux=malloc(sizeof(Nodo));
    nuevoNodo=malloc(sizeof(Nodo));
    if(aux!=NULL && nuevoNodo!=NULL && primero!=NULL){
        aux=primero;
        strcpy(nuevoNodo->nombre,val);
        while(posActual!=pos){
            aux=aux->siguiente;
            posActual++;
        }
 
 
        nuevoNodo->siguiente=aux->siguiente;
        aux->siguiente=nuevoNodo;
        nuevoNodo->anterior=aux;
        if(nuevoNodo->siguiente){
           // aux->siguiente->anterior=nuevoNodo;
        }
 
 
    }
    else{
         printf("NO HAY MEMORIA SUFICIENTE");
    }
 
 
}
 
void agregar(char *val){
    Nodo *nuevoNodo;
    nuevoNodo=malloc(sizeof(Nodo));
    if(nuevoNodo!=NULL){
        strcpy(nuevoNodo->nombre,val);
    }
    else{
        printf("ERROR, NO HAY MEMORIA DISPONIBLE");
    }
    if(primero==NULL){
        primero=nuevoNodo;
        ultimo=nuevoNodo;
    }else{
        nuevoNodo->anterior=ultimo;
        ultimo->siguiente=nuevoNodo;
        ultimo=nuevoNodo;
    }
}//funcion que agrega nodos al final de la lista
 
void imprimir(int dir){ //dir 1=adelante 2=atras
    Nodo *aux;
    aux=malloc(sizeof(Nodo));
    if(aux!=NULL && primero!=NULL){
        if (dir==1){
            aux=primero;
            while(aux!=NULL){
                printf("%s ->",aux->nombre);
                aux=aux->siguiente;
            }
        }
        if(dir==2){
            //completar recorrido inverso
            aux=ultimo;
            while(aux!=NULL){
                printf("%s <-",aux->nombre);
                aux=aux->anterior;
            }
        }
    }else{
        printf("ERROR LA LISTA NO TIENE ELEMENTOS O NO HAY MEMORIA SUFICIENTE");
    }
 
 
}
 
int main()
{
    agregar("uno");
    agregar("dos");
    agregar("tres");
    agregar("cuatro");
    agregarEnPosicion("dos punto cinco ",2);
    imprimir(1);
    imprimir(2);
 
    return 0;
}




Pero ahora despues de esto [Error] two or more data types in declaration specifiers
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar