Code:
#include <stdio.h>
#include <stdlib.h>

FILE *fp1;
int main()
{
typedef struct people{
char Firstname[10];
char Lastname[10];
char Phonenumber[10];
int  Seq_num;

struct people *Link;
} rec;


int Number;
int count;
int i;
rec *p;

printf("Please enter the source of the first matrix\n");

scanf("%s",matrix1_name);

fp1=fopen(matrix1_name,"r");
if(fp1==NULL)
printf("some error has occured ,but don't worry and you'll work it out");
else
printf("writing\n");
  
printf("Please tell me how much people's information in the file? \n");
scanf("%d", &Number);
  

p=(rec *)malloc(Number*sizeof(rec));//根據link01.c example知 ()內就是P的宣告

  



rec *f;
f=p;


printf("OK1\n");
for(i=0;i<=Number-1;i++){
fscanf(fp1,"%s %s %s",&(f->Firstname),&(f->Lastname),&(f->Phonenumber));
f=f->Link;
}

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);


printf("OK3\n");
/*while(f->Link!=NULL){
fscanf(fp1,"%s",&(f->Firstname));
fscanf(fp1,"%s",&(f->Lastname));
fscanf(fp1,"%s",&(f->Phonenumber));

}



printf("%s",f->Firstname);

/*count=0;
while(count!=Number-1){
f=f->Link;
count++;
}
f->Link=NULL;




fclose(fp1);
return 0;
}

Last edited by shabbir; 5Apr2009 at 22:14.. Reason: Code blocks