📄 lseek.cc
字号:
#include <iostream>using namespace std;#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>int main(){ int fd=open("file9",O_RDWR); if(fd<0){ cout << "cannot open file9" << endl; return -1; } for(int i=0; i<3; i++){ char a, b; lseek(fd, i, SEEK_SET); read(fd, &a, 1); lseek(fd, i+7, SEEK_SET); read(fd, &b, 1); lseek(fd, i, SEEK_SET); write(fd, &b, 1); lseek(fd, i+7, SEEK_SET); write(fd, &a, 1); } close(fd);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -