-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathfopen.cpp
More file actions
32 lines (26 loc) · 834 Bytes
/
fopen.cpp
File metadata and controls
32 lines (26 loc) · 834 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
struct FILE;
FILE *fopen(const char * path, const char * mode);
char * getenv(const char * name);
void test_fopen(char * filename1) {
const char * filename2 = "a_file";
FILE * file0 = fopen("a_file", "r");
FILE * file1 = fopen(filename1, "r");
FILE * file2 = fopen(filename2, "r");
}
const char * do_getenv() {
return getenv("FILENAME1");
}
FILE * do_fopen(const char * filename) {
return fopen(filename, "r");
}
void test_getenv()
{
const char * filename1 = do_getenv();
const char * filename2 = getenv("FILENAME2");
const char * filename4 = getenv("FILENAME4");
FILE * file0 = fopen(getenv("FILENAME0"), "r");
FILE * file1 = fopen(filename1, "r");
FILE * file2 = fopen(filename2, "r");
FILE * file3 = do_fopen(getenv("FILENAME3"));
FILE * file4 = do_fopen(filename4);
}