Linux下GCC编译通过了这段代码,可是执行的时候说段错误,求大神帮帮忙!
1 #include <stdio.h>2 #include <stdlib.h>
3 #include <fcntl.h>
4 #include <unistd.h>
5 #include <sys/mman.h>
6 #define BUFSIZE 1024 * 768 * 2
7
8 int main(int argc , char *argv[])
9 {
10 int fbfd;
11 unsigned short *buf;
12 int i, j;
13
14 fbfd = open("/dev/fb",O_RDWR);
15 buf = (unsigned short *)mmap(NULL, BUFSIZE, PROT_WRITE | PROT_READ, MAP_SHARED, fbfd, 0);
16
17 for(i = 0; i < 768; i++)
18 {
19 for(j = 0; j < 1024; j++)
20 {
21 buf[j + (i * 1024)] = 65535;
22 }
23 }
24 return EXIT_SUCCESS;
25
26 }