This repository was archived by the owner on Jun 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathid.c
More file actions
78 lines (70 loc) · 1.12 KB
/
id.c
File metadata and controls
78 lines (70 loc) · 1.12 KB
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "projecto.h"
int procura_id(int id){
int read_id;
FILE *f;
f = fopen("cancelamentos.txt", "r");
if (f!=NULL){
rewind(f);
while(feof(f)==0){
fscanf(f,"%d", &read_id);
if (read_id == id){
return 1;
}
}
}
return 0;
}
void save_id(List l){
FILE *f;
if(l->next!=NULL)
l=l->next;
f = fopen("id.txt","w");
if(f!=NULL){
rewind(f);
fprintf(f,"%d", l->id);
fclose(f);
}
else
printf("Erro!\n");
}
int load_id(){
int id=0;
FILE *f;
f=fopen("id.txt", "r");
if (f!=NULL){
rewind(f);
fscanf(f,"%d",&id);
fclose(f);
}
else
printf("Erro!\n");
return id;
}
int search_id(int id){
int read_id=0;
FILE *f;
f=fopen("passagens.txt", "r");
if (f!=NULL){
rewind(f);
while(feof(f)==0){
fscanf(f,"%d", &read_id);
if(read_id == id)
return 1;
}
}
return 0;
}
void save_id2(List2 l){
FILE *f;
while(l->next!=NULL)
l=l->next;
f = fopen("id.txt","w");
if(f!=NULL){
rewind(f);
fprintf(f,"%d", l->id);
fclose(f);
}
}