-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclient.cpp
More file actions
118 lines (103 loc) · 2.3 KB
/
Copy pathclient.cpp
File metadata and controls
118 lines (103 loc) · 2.3 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
enum command {send, fetch};
typedef struct message {
string sn;//sender name
string rn;//recevier name
string subject;//message subject
string body;// the main body of text
} message_t;
void store_message_to_file(message_t m)
{
ofstream omessage;
omessage.open("text.txt");
//omessage.open("thefile.txt");
omessage << m.sn << endl << m.rn << endl << m.subject << endl << m.body << endl;
omessage.close("text.txt");
}
message_t read_message()
{
message_t m;
cout << "please input your name" << endl;
cin >> m.sn;
cout << "please input the recevier's name" << endl;
cin >> m.rn;
cout << "please input your subject title" << endl;
cin>> m.subject;// subject
cout << "Please give the body of your message"<<endl;
cin >> m.body;
cout << "success" << endl;
return m;
}
void message_info();
{
char info[20];
cout<<"Please enter the name of the sender to the message you want to fetch"<<endl;
cin>>info;
//function call to the function to store that info and send to appache
}
void ask_user()
{
int result=0;
char operation[10];
char send[4];
char fetch[5];
memset(send,0,4);
memset(fetch,0,5);
strcpy(send,"Send");
strcpy(fetch, "fetch");
cout<<"Would you like to send or fetch your message"<<endl;
cin>>operation;
result =strcmp(operation, fetch);
if (result==0)
{
//function call to the function to store the info in a file then return sucess or fail
}
else
{
message_info();
}
}
void sendA()
{
string str;
cout << "please input the receiver" << endl;
cin >> str;
fstream message;
message.open("receiver.txt");
message << str;
send_to_apache(str, "receiver.txt");
}
int main()
{
message_t m;
m=read_message();
store_message_to_file(m);
ask_user();
sendA();
system("pause");
}
/*
The below code is the code that reads a file and copies it into another file while deleting the orginal
#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
using namespace std;
int main()
{
ifstream infile("input.txt");
ofstream outfile("output.txt");
string str = " ";
while (!infile.eof())
{
str += infile.get();
}
infile.close();
remove("input.txt");
outfile << str;
outfile.close();
}
*/