0
Hello I would like to know what to insert in the conditional within the function, to add the elements at the end of the list while they are different from 0... I’ve tried several ways and I couldn’t...
typedef struct node{ // Struct para ser usada como nó...
int data;
struct node *next;
};
void insert(node *lista, int a){ // Adicionar elementos no fim da lista
node *ptr = (node *)malloc(sizeof(node));
ptr->data = a;
if(){
}else{
}
int main(){
//Variáveis
int n = 1, // Número que vai ser adicionado
node *lista; // Lista
while(n!=0){
printf("Que numero adicionar?\n");
scanf("%d", &n);
insert(lista, n);
}
Dude, I don’t know if you’re using any library, but I use dev c++, it says here that on line 7 the NULL is not declared in scope
– Raythan Machado
I have not used any library besides stdio and stdlib. I think if you replace NULL with 0 is equivalent. But NULL should work.
– Ken
It really worked man, thank you =)
– Raythan Machado