I am unable to get my linked list to print out after finishing the code. I am just learning pointers so that is where the problem is most likely. I am also not sure if I used the correct type of loop to do this.
#include <stdio.h>
#include <stdlib.h>
typedef struct node {
int fld1;
char fld2;
struct node *next;
} node;
int main(void) {
struct head {
struct node *first;
int count;
} head;
int x;
char y;
node *newptr;
node *currentptr;
node *previousptr;
head.first = NULL;
head.count = 0;
int zz = 1;
int i;
do {
printf("Enter a value between 1 and 10: ");
scanf(" %i", &x);
printf("Enter a letter: ");
scanf(" %c", &y);
printf("in");
newptr = (node*)malloc(sizeof(node));
newptr->fld1=x;
newptr->fld2=y;
if (head.first == NULL) {
head.first = newptr;
head.count++;
newptr-> next == NULL;
} else {
currentptr = head.first;
if (currentptr->next == NULL) {
head.count++;
currentptr->next = newptr;
newptr->next = NULL;
} else {
currentptr = currentptr->next;
int i;
for (i = 1; i < head.count; i++){
if (currentptr->next == NULL) {
currentptr->next = newptr;
} else {
currentptr = currentptr->next;
}
head.count++;
}
}
printf("%d\n %c\n", head.count, newptr);
}
} while (x != 99);
}