-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImportAndExport.c
More file actions
40 lines (27 loc) · 922 Bytes
/
ImportAndExport.c
File metadata and controls
40 lines (27 loc) · 922 Bytes
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
FILE *fpointer; // for reading
FILE *fcopy; // for copying
//Wrinting
fpointer = fopen("Pokedex","w"); // w = write, r = read, a = append
for (i = 0; i < 100; i++)
{
fprintf(fpointer, "%d \n", num[i]);
}
fclose(fpointer);
//Reading
fpointer = fopen("Pokedex.txt","r"); // w = write, r = read, a = append ; for opening the file
for (i = 0; i < MAX; i++)
{
fscanf(fpointer, " %d", &num2[i]); // trying to scan everything, automatically na magiiscan to the next line to sabi daw
}
fclose(fpointer); // file closing
for (i = 0; i < MAX; i++) // test print for loop
{
printf("%d, ",num2[i]);
}
//Copying
fcopy = fopen(inName,"a"); // w = write, r = read, a = append ; copying the file
for (i = 0; i < MAX; i++)
{
fprintf(fcopy," %d\n", num2[i]); //copying the file
}
fclose(fcopy); // closing it