Hello all,
I am writing a simple program (using data strcutures) to capture vowels and thier ascii equivalent from the user. I know thats too simple to be using data structures, but he point is to practice them.
THe problem is that i am getting an error saying that i didn't declare a pointer called "nodo" (which i clearly did as the code would illustrate), maybe I made a mistake somewhere, thanks alot guys. Here's the code:
#include<stdio.h>
#define null 0;
struct lista{
char vocal;
int ascii;
struct lista *liga,*nodo;
};
struct lista *inicio;
char voc; int ascii;
char respuesta;
int main()
{
inicio=(struct lista*)malloc(sizeof(struct lista));
printf("\n\t introduce el voval");
scanf("%c",&voc);
(*inicio).vocal=voc;
printf("\n\t Introduce el ascii para %c",voc);
scanf("%i",&ascii);
(*inicio).ascii=ascii;
(*inicio).liga=null;
do{
nodo=(struct lista*)malloc(sizeof(struct lista));
printf("\n\tIntroduce vocal");
scanf("%c",&voc);
(*nodo).vocal=voc;
printf("\n\tintroduce el asicii para %c",voc);
scanf("%i",&ascii);
(*nodo).ascii=ascii;
(*nodo).liga=inicio;
inicio=nodo;
printf("\n\t Quieres continuar? si(s)/no(n)");
scanf("%c",&respuesta);
}while(respuesta!='n');
return 0;
}
I am writing a simple program (using data strcutures) to capture vowels and thier ascii equivalent from the user. I know thats too simple to be using data structures, but he point is to practice them.
THe problem is that i am getting an error saying that i didn't declare a pointer called "nodo" (which i clearly did as the code would illustrate), maybe I made a mistake somewhere, thanks alot guys. Here's the code:
#include<stdio.h>
#define null 0;
struct lista{
char vocal;
int ascii;
struct lista *liga,*nodo;
};
struct lista *inicio;
char voc; int ascii;
char respuesta;
int main()
{
inicio=(struct lista*)malloc(sizeof(struct lista));
printf("\n\t introduce el voval");
scanf("%c",&voc);
(*inicio).vocal=voc;
printf("\n\t Introduce el ascii para %c",voc);
scanf("%i",&ascii);
(*inicio).ascii=ascii;
(*inicio).liga=null;
do{
nodo=(struct lista*)malloc(sizeof(struct lista));
printf("\n\tIntroduce vocal");
scanf("%c",&voc);
(*nodo).vocal=voc;
printf("\n\tintroduce el asicii para %c",voc);
scanf("%i",&ascii);
(*nodo).ascii=ascii;
(*nodo).liga=inicio;
inicio=nodo;
printf("\n\t Quieres continuar? si(s)/no(n)");
scanf("%c",&respuesta);
}while(respuesta!='n');
return 0;
}