college assignment,text file~

i can read the first customer detail only,others cant read....how it work to read all customer?
here my code~

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
void main() {
system("color 8a");

SYSTEMTIME t;
int choice, txnCode;


/*TARBANK Logo
printf("\n\ ========== __ ~~~~> ~~~~>\n");
printf("\n\||===||===|| / \ | @@ > | @@ >\n");
printf("\n\ || / /_ \ | @ > | >\n");
printf("\n\ || / /__\ \ | << | <<\n");
printf("\n\ || / / \ \ | \ \ | @@ >\n");
printf("\n\ || /_/ \_\ | \ \ |___ >\n");
*/	

//Display Today's Date and Time
GetLocalTime(&t);
printf("\t\tDate! Today is %d/%d/%d and \n\
it's %d:%d:%d now.\n\n", t.wDay, t.wMonth, t.wYear, t.wHour, t.wMinute, t.wSecond);

printf("\t\tCustomer:Press 1\n");
printf("\t\tManager:Press 2\n\n");
printf("\t\tYour choice: ");
scanf("%d", &choice);
if(choice == 1) {
fptr1 = fopen("Customer.txt", "r");
fptr2 = fopen("Customer_temp.txt", "w");

//Check if customer.txt can be opened or not
if(fptr1 == NULL || fptr2 == NULL) {
printf("ERROR in opening file!Try again.....");
exit(-1);
}

//Randomly generate ATM No.(6-10)
srand(time(NULL));
atm = (rand() % 5) + 6;
//Display ATM No.
printf("ATM No: %d\n", atm);

//Prompt and read user's A/C No.
printf("\t\tPlease enter your A/C No:\t\t_____\b\b\b\b\b");
scanf("%s", &temp.accNo);
fflush(stdin);

//Prompt and read user's PIN No.
printf("\t\tPlease enter your PIN No:\t\t_____\b\b\b\b\b");
scanf("%s",temp.PIN);
fflush(stdin);

//Read customer.txt
while(!feof(fptr1)) {
for(int i = 0; i < 10; i++) {
fscanf(fptr1, "%[^|]|%[^|]|%[^|]|%c|%[^|]|%[^|]|%[^|]|%d|%d%d%d%d%d%d", 
&customer[i].accNo, &customer[i].PIN, &customer[i].name, &customer[i].gender, 
&customer[i].address, &customer[i].state, &customer[i].contact, 
&customer[i].balance, &customer[i].lastTxn.date, &customer[i].lastTxn.month, &customer[i].lastTxn.year, 
&customer[i].lastTxn.hr, &customer[i].lastTxn.min, &customer[i].lastTxn.sec);

//Check if the results match(update is pending)
if(strcmp(temp.accNo, customer[i].accNo) == 0 && strcmp(temp.PIN, customer[i].PIN) == 0) {
customerCode = i;

strcpy(temp.name, customer[i].name);
temp.balance = customer[i].balance;

temp.gender = customer[i].gender;
strcpy(temp.address, customer[i].address);
strcpy(temp.state, customer[i].state);
strcpy(temp.contact, customer[i].contact);
temp.lastTxn.year = customer[i].lastTxn.year;
temp.lastTxn.month = customer[i].lastTxn.month;
temp.lastTxn.date = customer[i].lastTxn.date;
temp.lastTxn.hr = customer[i].lastTxn.hr;
temp.lastTxn.min = customer[i].lastTxn.min;
temp.lastTxn.sec = customer[i].lastTxn.sec;
}
}
}

printf("\n");
printf("Name: %s\n\n", temp.name);
printf("Balance: RM%d\n\n", temp.balance);

printf("Last Transaction Date: %d/%d/%d %d:%d:%d\n\n", temp.lastTxn.date, temp.lastTxn.month, temp.lastTxn.year, 
temp.lastTxn.hr, temp.lastTxn.min, temp.lastTxn.sec);

here is the customer.txt~
12345|54321|Tao Ka Cheng |M|12 Jalan 3/45 KL |Wilayah P|012-3456789|5000| 3 10 2015 2 30 00
12350|05321|Lim Ke Yuan |F|13 Jln 5/50 Gtown |Penang |013-4567890|4000| 4 10 2015 4 30 00
12355|55321|Lin Lao ba |F|14 Jalan 7/15 KK |Sabah |014-5678901|2000| 4 10 2015 2 00 00
12360|06321|Chau Ah Gua |M|15 Jalan 2/25 Ipoh |Perak |015-6789012|3000| 5 10 2015 4 30 00
12365|56321|Marempit Chong|M|16 Jalan 1/34 Muar |Johor |016-7890123|5000| 7 10 2015 8 30 00
12370|53344|Kang Mei Mei |F|17 Jalan 6/45 SP |Sungai P |012-1234489|6000| 6 10 2015 2 30 00
12375|02543|Lu Ka Jik |M|18 Jln 9/50 Gtown |Penang |013-5456790|8000| 8 10 2015 4 30 00
12380|08333|Wong Ji Ji |F|19 Jalan 1/60 KK |Sabah |014-5754301|1000| 12 10 2015 2 10 00
12385|01232|Chau JohnCena |M|20 Jalan 45/65 Ipoh|Perak |015-6778912|4500| 17 10 2015 4 40 00
12390|33452|Jessyna Lai |F|21 Jalan 12/34 Muar|Johor |016-1232023|7000| 27 10 2015 8 50 00
Last edited on
Hi,

You should use code tags to make your code easier to read :
http://www.cplusplus.com/articles/jEywvCM9/
Topic archived. No new replies allowed.