linux ,编写一个程序,把一个文件复制到另一个文件上
即实现简单的copy功能
要求:只用 open() read() write() 和close()系统调用.
cat file1 >> file2 ?
open()连个文件,read()其中一个内容,write()到另外一个文件上,最后close()掉。
能不能用lseek函数?
C/C++ code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define BUF_SIZE 1024*8
int main()
{
int fds, fdd;
char buf[BUF_SIZE];
size_t hasread = 0;
fds = open("filea", O_RDONLY);
fdd = open("fileb", O_WRONLY, O_CREAT);
if(fds && fdd)
{
while((hasread = read(fds, buf, sizeof(buf))) > 0)
{
write(fdd, buf, hasread);
}
close(fds);
close(fdd);
}
不好意思,少copy半边“}”
非常好
相关问答:
使用Struts2上传文件,在linux下报错
2009-09-29 14:56:20,801 [org.apache.struts2.interceptor.FileUploadInterceptor]-[ERROR] Processing of multipart/form-data request failed. c:/temp/upload__1dcd07ee_12 ......
一直用svn来做资源的管理,
现在发现windows下取svn 要10个小时左右(资源大约有20G,全是小文件)
linux下取仅用40分钟,
请问linux的文件系统在哪儿比windows文件系统强力?
svn 可够慢的。
在 ......
我们隶属中科院计算所网络重点实验室(http://www.ict.ac.cn/survey/channel/detail443.asp)基础设施课题组.
现因项目和业务拓展的需要,特需要招聘与项目相关的网络应用工程师1-2名。
具体要求如下。有意者 ......
我要写个服务端。 要求同时支持windows 和 linux 两个 系统。 也就是要写一个 dll和一个so 文件。由于我一直都是在winds下写程序。linux的还不会。 向大家咨询 同时 支持 dll和so 应该怎么写。
用纯c/c ......
请教:
在 LINUX系统中的ORACLE怎么新建表空间?
一样的命令啊。如果没用omf的话,你就指定下路径和数据文件名就行了。
create tablespace xxx datafile '/u01/..../aaa.dbf' size 10m;
CREATE TA ......