Thanks for all of the replies. I see what you guys mean about the form it is in and have changed the code so that it shouldn't be as confusing. Here is the changed code:
Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct node {
int value;
struct node *next;
} node;
void createNewNode(node *head, node *newNode);
void printList(node *head);
int main(int argc, const char * argv[]) {
node *first;
first = malloc(sizeof(node));
node *newNode;
newNode = malloc(sizeof(node));
int numberOfEntries = 0;
first->next = NULL;
printf("Number of Entries: ");
scanf("%d", &numberOfEntries);
printf("\n");
if(numberOfEntries == 1) {
printf("Enter Value: ");
scanf("%d", first->value);
printf("\n");
} else {
int i = 0;
while(i < numberOfEntries) {
printf("Enter Value: ");
scanf("%d", first->value);
printf("\n");
createNewNode(first, newNode);
i++;
}
}
printList(first);
return 0;
}
void createNewNode(node *head, node *newNode) {
newNode->next = head;
head = newNode;
}
void printList(node *head) {
node *current;
current = malloc(sizeof(node));
current = head;
while(current->next != NULL) {
printf("Entry: %d\n", current->value);
current = current->next;
}
printf("Entry: %d\n", current->value);
free(current);
}
I am still pretty lost with what else is wrong with the code.... Linked lists are confusing the hell out of me lol