-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
52 lines (41 loc) · 973 Bytes
/
main.cpp
File metadata and controls
52 lines (41 loc) · 973 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
#include <iostream>
#include <fstream>
#include "md5.h"
using namespace std;
int main()
{
fstream file; //object of fstream class
char thing[1000];
//opening file "sample.txt" in out(write) mode
file.open("sample.txt",ios::out);
if(!file)
{
cout<<"Error in creating file!!!"<<endl;
return 0;
}
cout<<"File created successfully."<<endl;
//write text into file
file<<"ABCD.";
//closing the file
file.close();
//again open file in read mode
file.open("sample.txt",ios::in);
if(!file)
{
cout<<"Error in opening file!!!"<<endl;
return 0;
}
//read untill end of file is not found.
char ch; //to read single character
while(!file.eof())
{
file>>ch; //read single character from file
cout<<ch <<thing;
}
file.close(); //close file
fstream f;
f.open("ei.txt",ios::out);
f<<md5(thing);
f.close();
return 0;
}