40 lines
523 B
C
40 lines
523 B
C
#include <cs50.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
typedef struct node
|
|
{
|
|
int number;
|
|
struct node *next;
|
|
} node;
|
|
|
|
int main(void)
|
|
{
|
|
node *list = NULL;
|
|
|
|
for (int = 0; i < 3; i++)
|
|
{
|
|
node *n = malloc(sizeof(node));
|
|
if (n == NULL)
|
|
{return 1;}
|
|
// n-> = NULL;
|
|
(*n).number = get_int("Number: ");
|
|
// n-> = NULL;
|
|
(*)n.next = NULL;
|
|
|
|
// Prepend node to list
|
|
n->next = list
|
|
list =n;
|
|
}
|
|
|
|
// Print Numbers
|
|
node *ptr = list;
|
|
while (ptr !=NULL)
|
|
{
|
|
printf("%i\n", ptr->number);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|