郁闷阿
时间:2011-07-12
来源:互联网
C/C++ code
编译Steven大神的代码,后
root@suma:/home/suma/桌面# cc test.c
root@suma:/home/suma/桌面# ./a.out test.c mm.c
root@suma:/home/suma/桌面# od -c mm.c
0000000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
*
0002100 \0 \0 \0 \0 \0 \0 \n
0002110
用gedit也没法看,大家给个情况,谢谢
#include "apue.h" #include <fcntl.h> #include <sys/mman.h> int main(int argc,char **argv) { int fdin,fdout; void *src,*dst; struct stat statbuf; if(argc!=3) err_quit("usge: %s <fromfile> <tofile>",argv[0]); if((fdin=open(argv[1],O_RDONLY))<0) err_sys("can not open %s for reading",argv[1]); if((fdout=open(argv[2],O_RDWR | O_CREAT | O_TRUNC,FILE_MODE))<0) err_sys("can not create %s for wrtting",argv[2]); if(fstat(fdin,&statbuf)<0) err_sys("fstat error"); if(lseek(fdout,statbuf.st_size-1,SEEK_SET)==-1) err_sys("lseek error"); if(write(fdout," ",1)!=1) err_sys("write error"); if((src=mmap(0,statbuf.st_size,PROT_READ,MAP_SHARED,fdout,0))==MAP_FAILED) err_sys("mmap error for output"); if((dst=mmap(0,statbuf.st_size,PROT_READ | PROT_WRITE,MAP_SHARED,fdout,0))==MAP_FAILED) err_sys("mmap error for output"); memcpy(dst,src,statbuf.st_size); msync(src,statbuf.st_size,MS_SYNC); exit(0); }
编译Steven大神的代码,后
root@suma:/home/suma/桌面# cc test.c
root@suma:/home/suma/桌面# ./a.out test.c mm.c
root@suma:/home/suma/桌面# od -c mm.c
0000000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
*
0002100 \0 \0 \0 \0 \0 \0 \n
0002110
用gedit也没法看,大家给个情况,谢谢
作者: suma2012 发布时间: 2011-07-12
对了系统是ubuntu,test.c就是源文件
作者: suma2012 发布时间: 2011-07-12
./a.out 不能运行吗?
作者: abao623660072 发布时间: 2011-07-12
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28