![]() |
A C language problem in link list traversal
Hi guys,
I've difficulties in developing a new link list by a loop First of all, i let the user enter people's number: Numbger And create an empty link list And then read data to link list by for loop. rec *f; //by using another pointer f=p; //f indicates to the node which p indicates to printf("OK1\n");//for my test for(i=0;i<=Number-1;i++){ fscanf(fp1,"%s %s %s",&(f->Firstname),&(f->Lastname),&(f->Phonenumber)); f=f->Link; } //在嘗試用回圈 寫入number比資料入link list時發生了問題 //while I 'm using a loop to enter messages to nodes , //errors occur in the statement f=f->Link; //But WHY?><" //If i can'g use a loop , then what should i do ? printf("OK2\n"); printf("%s\n",f->Firstname); printf("%s\n",f->Lastname); printf("%s\n",f->Phonenumber); printf("%s\n",f->Link->Firstname); printf("%s\n",f->Link->Lastname); printf("%s\n",f->Link->Phonenumber);//for testing the date be written or not? printf("OK3\n"); Thank you for your help >(_ _)< |
Re: A C language problem in link list traversal
How is rec defined?
|
Re: A C language problem in link list traversal
typedef struct people{
char Firstname[10]; char Lastname[10]; char Phonenumber[10]; int Seq_num; //the larger number in Seq_num stands for the smaller number in value. struct people *Link; } rec; |
Re: A C language problem in link list traversal
Code:
#include <stdio.h> |
Re: A C language problem in link list traversal
You haven't set p to point to memory that contains the rec structures in which to place the values.
|
| All times are GMT +5.5. The time now is 01:29. |