-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.cpp
46 lines (39 loc) · 897 Bytes
/
index.cpp
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
#include<bits/stdc++.h>
#include<fstream>
#include<string>
using namespace std;
int main()
{
ifstream myfile;
int counter = 0;
myfile.open("laptop_list.txt");
string mystring;
string tmpstring;
if ( myfile.is_open() ) {
while ( getline (myfile,mystring) )
{
if( mystring[0]=='#')
{
ofstream tempfile;
tempfile.open(to_string(counter)+".txt");
tempfile<<tmpstring;
tempfile.close();
tmpstring=mystring;
counter++;
}
else
{
// tmpstring.copy(mystring);
tmpstring +=mystring;
}
//Printing the output of the file contents
cout << mystring << '\n';
}
}
ofstream tempfile;
tempfile.open(to_string(counter)+".txt");
tempfile<<tmpstring;
tempfile.close();
cout<<"hello world";
return 0;
}