write a bit of code to read from a file and compare a string but it dies before it finishes.
the complier tells me there is a segment fault on line 31 can anyone help.
[LIST=1]
[*]#include <stdio.h>
[*]#include <string.h>
[*]#include <stdlib.h>
[*]#define max 100
[*]struct customer{
[*]
[*] char Fname[20];
[*] char Lname[20];
[*] char Address[80];
[*] int lastTrans;
[*]}*cus[max];
[*]main()
[*]{
[*] FILE *fptr;
[*] char *filename = "index";
[*] int i=0;
[*]
[*] char name[20];
[*]
[*]
[*] printf("name : ");
[*] scanf("%s",&name);
[*]
[*]
[*]
[*] fptr = fopen(filename,"rb");
[*]
[*] while(!feof(fptr))//this is where it say's there is a 'segment fault'
[*] {
[*] fscanf(fptr,"%s%s%s%d",&cus[i]->Fname,&cus[i]->Lname,&cus[i]->Address,&cus[i]->lastTrans);
[*] printf("%s %s\t%s\t%d\n",cus[i]->Fname,cus[i]->Lname,cus[i]->Address,cus[i]->lastTrans);
[*] i++;
[*]
[*] if(!strcmp(name,cus[i]->Fname ))
[*] {
[*] printf("found %s",name);
[*] break;
[*] }
[*] }
[*] system("pause");
[*]}
[/LIST]