-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfbitstr_putc.c
More file actions
39 lines (32 loc) · 849 Bytes
/
fbitstr_putc.c
File metadata and controls
39 lines (32 loc) · 849 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
#include <stdio.h>
#include <stdlib.h>
#include "stdefine.h"
#include "bitstr.h"
#include "bitstr.c"
int main(int argc, char *argv[]) {
if (argc != 2) {
fprintf(stderr, "Usage: %s <input_file>\n", argv[0]);
return 1;
}
// 打开文件
FILE *inputFile = fopen(argv[1], "r");
if (!inputFile) {
fprintf(stderr, "Error opening file: %s\n", argv[1]);
return 1;
}
// 读取文件中的字符
int c;
if (fscanf(inputFile, "%d", &c) != 1) {
fprintf(stderr, "Error reading character from file.\n");
fclose(inputFile);
return 1;
}
// 关闭文件
fclose(inputFile);
// 设置stream为BITSTR_FILE类型
int stream_type = BITSTR_FILE;
void *stream = &stream_type;
// 调用bitstr_putc函数
bitstr_putc(c, stream);
return 0;
}