what i've got so far on the linked list
Here's what I've got so far on the linked list: It runs, but does not display the five inputs-instead i think it's displaying their addresses. Also I will need to adapt this program to prompt fot 1 more entry and to display the new list with the new entry.
insert
Code:
#include <stdafx.h>
#define maxnum 10
struct value
{
int num[maxnum];
struct value*nextaddr;
};
int _tmain(int argc, _TCHAR* argv[])
{
int a,b,c,d,e,f;
printf("please enter five numbers:");
scanf("%f,%f,%f,%f,%f", &a,&b,&c,&d,&e,&f);
struct value t1={a};
struct value t2={b};
struct value t3={c};
struct value t4={d};
struct value t5={e};
struct value *first;
void display (struct value*);
first=&t1;
t1.nextaddr=&t2;
t2.nextaddr=&t3;
t4.nextaddr=&t5;
t5.nextaddr=NULL;
display (first);
return 0;
}
void display(struct value*contents)
{
while (contents!=NULL)
{
printf("%-5d", contents->num);
contents=contents->nextaddr;
}
}