I have a question about this exercise. I tried in several ways but I do not know how to get the position of the pointer to use the content in that case.
• Describe the steps for creating a new element in the list? Develop an algorithm to create an empty chained list. Then create a function that allows you to insert elements into it. Finally, display the even values in the list
#include <stdio.h>
#include <stdlib.h>
typedef struct Lista
{
int dado;
struct Lista *prox;
} lista;
lista *insere (lista *prox, int dadoEnviado)
{
lista *novo;
novo = (lista *)malloc(sizeof(lista));
novo->dado = dadoEnviado;
novo->prox = prox;
return novo;
}
/*void imprime(lista *pont){
lista *p;
for( p = pont; p!=NULL; p=p->prox){
printf("%d --",p->dado);
//}
}*/
void imprimePar(lista *l)
{
lista *p;
for( p = l; p!=NULL; p=p->prox)
{
if( p->dado % 2 == 0)
{
printf("%d",p->dado);
}
}
}
main()
{
lista *pont;
pont = NULL;
pont = insere(pont, 10);
pont = insere(pont, 20);
pont = insere(pont, 30);
//imprime(pont);
imprimePar(pont);
}