-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path155.cpp
More file actions
66 lines (54 loc) · 1003 Bytes
/
155.cpp
File metadata and controls
66 lines (54 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include<unistd.h>
#include<iostream>
using namespace std;
class FileConcat
{
public:
int fd1,fd2;
FileConcat(char Fname[],char Sname[])
{
fd1=open(Fname,O_RDWR);
fd2=open(Sname,O_RDWR|O_APPEND);
if(fd1==-1 ||fd2==-1)
{
cout<<"Unable to open file"<<endl;
}
else
{
cout<<"File Opened Successfully"<<endl;
}
}
void FileConcatX()
{
char Arr[10];
int ret=0;
while((ret=read(fd1,Arr,10))!=0)
{
write(fd2,Arr,ret);
//cout<<Arr;
//write(1,Arr,ret);
}
//cout<<"\n";
}
~FileConcat()
{
close(fd1);
close(fd2);
}
};
int main()
{
char str1[20],str2[20];
char ch='\0';
int iRet=0;
cout<<"Enter First File name"<<endl;
cin>>str1;
cout<<"Enter Second File name"<<endl;
cin>>str2;
FileConcat obj(str1,str2);
obj.FileConcatX();
return 0;
}