-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimplebankacc.c
62 lines (61 loc) · 2 KB
/
simplebankacc.c
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
//
// Created by user on 6/16/23.
//
#include <stdio.h>
int main(){
FILE *fptr;
int id;
double balence;
char name[20];
int option = 0;
if((fptr = fopen("/home/user/C-for-Industry/clients.dat","r"))== NULL){
printf("Error opening file\n");
}
else{
printf("%s",
"check point\n"
"1-Display balence zero accounts\n"
"2-Display credit accounts\n"
"3-Display debit accounts\n"
"4-End Process?\n");
scanf("%d",&option);
while( option != 4){
fscanf(fptr, "%d%s%lf", &id, name, &balence);
switch(option){
case 1:
printf("%-10s %-13s %s\n", "ID", "Name", "Balence");
while(!feof(fptr)) {
if(balence == 0) {
printf("%-10d %-13s %lf\n", id, name, balence);
}
fscanf(fptr, "%d%s%lf", &id, name, &balence);
}
break;
case 2:
printf("%-10s %-13s %s\n", "ID", "Name", "Balence");
while(!feof(fptr)) {
if(balence < 0) {
printf("%-10d %-13s %lf\n", id, name, balence);
}
fscanf(fptr, "%d%s%lf", &id, name, &balence);
}
break;
case 3:
printf("%-10s %-13s %s\n", "ID", "Name", "Balence");
while(!feof(fptr)) {
if(balence > 0) {
printf("%-10d %-13s %lf\n", id, name, balence);
}
fscanf(fptr, "%d%s%lf", &id, name, &balence);
}
break;
}
rewind(fptr);
printf("?\n");
scanf("%d",&option);
}
printf("end of run");
fclose(fptr);
}
return 0;
}