Link List

I wrote the following program to accept integers then disply the linked list. seems to be working fine, except it disply punch of one's (1) and I dont know why, can I get some help please?? Thank you
#include <stdio.h>
struct number_list
int number;
struct number_list *nextnumber;

int numbers;
struct number_list t1 = {scanf("%d", &numbers)};
struct number_list t2 = {scanf("%d", &numbers)};
struct number_list t3 = {scanf("%d", &numbers)};
struct number_list t4 = {scanf("%d", &numbers)};
struct number_list t5 = {scanf("%d", &numbers)};
struct number_list t6 = {scanf("%d", &numbers)};
struct number_list t7 = {scanf("%d", &numbers)};
struct number_list t8 = {scanf("%d", &numbers)};
struct number_list t9 = {scanf("%d", &numbers)};
struct number_list t10 = {scanf("%d", &numbers)};
struct number_list *first;

first = &t1;
t1.nextnumber = &t2;
t2.nextnumber = &t3;
t3.nextnumber = &t4;
t4.nextnumber = &t5;
t5.nextnumber = &t6;
t6.nextnumber = &t7;
t7.nextnumber = &t8;
t8.nextnumber = &t9;
t9.nextnumber = &t10;
t10.nextnumber = NULL;
int contents = 0;
while (contents <1)
printf ("\n %d\n %d\n %d\n %d\n %d\n %d\n %d\n %d\n %d\n %d\n\n",
first->number, t1.nextnumber->number, t2.nextnumber->number,t3.nextnumber->number, t4.nextnumber->number, t5.nextnumber->number,
t6.nextnumber->number, t7.nextnumber->number, t8.nextnumber->number,
return 0;
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

tdubroffConnect With a Mentor Commented:
Scanf returns the number of parameters it read.  In this case it reads 1 number every time.  Therefore, first do the scanf() then create your struct with the numbers value.

All Courses

From novice to tech pro — start learning today.