-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest3.c
43 lines (36 loc) · 815 Bytes
/
test3.c
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
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
int lcd;
void test() {
int k, i, sum;
char s[3];
memset(s, '2', sizeof(s));
printf("test begin!\n");
k = lseek(lcd, 4, SEEK_CUR);
printf("lseek = %d\n", k);
k = write(lcd, s, sizeof(s));
printf("written = %d\n", k);
k = lseek(lcd, 0, SEEK_END);
printf("lseek = %d\n", k);
k = lseek(lcd, -4, SEEK_END);
printf("lseek = %d\n", k);
}
void initial(char i) {
char s[10];
memset(s, i, sizeof(s));
write(lcd, s, sizeof(s));
char c[20] = "";
int k = lseek(lcd, 0, SEEK_SET);
printf("lseek = %d\n", k);
}
int main(int argc, char **argv) {
lcd = open("/dev/onebyte", O_RDWR);
if (lcd == -1) {
printf("unable to open device");
exit(EXIT_FAILURE);
} initial('1');
test();
close(lcd);
return 0;
}