?? test8_8.txt
字號:
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
int write_buffer(int fd, const void *buf, int count);
int main(void)
{
int outfile;
char *mapped;
char *ptr;
int count;
if(outfile=open("test.dat", O_RDWR|O_CREAT|O_TRUNC, 0640)==-1)
{
printf("COULDN’T OPEN THIS FILE!\n");
exit(254);
}
lseek(outfile, 1000, SEEK_SET);
if(write(outfile, "\0",1)==-1)
{
printf("ERROR, WRITE FAILED!\n");
exit(254);
}
mapped=mmap(NULL, 1000, PROT_READ|PROT_WRITE,MAP_SHARED, outfile, 0);
if(!mapped)
{
printf("ERROR, MMAP FAILED!\n");
exit(254);
}
for(count=0; count<1000; count++)
{
if(*(mapped+count)>=97&&*(mapped+count)<=122)
*(mapped+ count)-= 32;
}
msync(mapped, 1000, MS_SYNC);
munmap(mapped,1000);
if(!close(outfile))
{
printf("POSSIBLY SERIOUS ERROR,CLOSE FILE FAILED");
exit(254);
}
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -