-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutput.cpp
59 lines (47 loc) · 1015 Bytes
/
output.cpp
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
#include"output.h"
FILE *fout = NULL;//输出文件指针
/*output_onefile_open:打开输出的单个文件*/
bool output_onefile_open(void) {
errno_t err;
err = fopen_s(&fout, "result.txt", "w");
if (err == 1)
{
printf("can't open the file\n");
fclose(fout);
return(false);
}
else
return(true);
}
bool output_file_open(char *file) {
errno_t err;
err = fopen_s(&fout, file, "w");
if (err == 1)
{
printf("can't open the file\n");
fclose(fout);
return(false);
}
else
return(true);
}
/*output_onefile_close:关闭输出单文件*/
void output_onefile_close(void) {
fclose(fout);
return;
}
/*output_print_code:输出字符数*/
void output_print_code(long num) {
fprintf(fout, "characters:%ld\n", num);
return;
}
/*output_print_line:输出行数*/
void output_print_line(long num) {
fprintf(fout, "lines:%ld\n", num);
return;
}
/*output_print_word:输出单词数*/
void output_print_word(long num) {
fprintf(fout, "words:%ld\n", num);
return;
}