自己写的
//copy1.cc
#include <iostream>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
using namespace std;
int main()
{
string filename="/mnt/hgfs/temp/hello/test.dat";
char* p=(char*)filename.c_str();
if(access(p, F_OK) != 0)
{
cout << "file not found......" << endl;
return 0;
}
int fin = open(p, O_RDONLY, 0777);
char buff[1024] = {'\0'};
int len = 0;
while((len = read(fin, buff, sizeof(buff))) > 0)
{
for(int i=0;i<len;i++)
cout<<buff[i];
}
close(fin);
return 0;
}