pb/z13
This commit is contained in:
parent
aa13833071
commit
4d82d1d64f
3 changed files with 104 additions and 0 deletions
36
1sem/programming basics/z13/37.cpp
Normal file
36
1sem/programming basics/z13/37.cpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
// pb_z13_37.cpp
|
||||
// Горбацевич Андрей
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#define MAX_STRING 500
|
||||
|
||||
using namespace std;
|
||||
|
||||
void join(const char *sep, istream &ist, ostream &ost);
|
||||
|
||||
int main() {
|
||||
ifstream inf("in.txt");
|
||||
ofstream fout("out.txt", ios::trunc);
|
||||
if (!inf.is_open() || !fout.is_open())
|
||||
{
|
||||
cerr << "Unable to open file" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
string sep;
|
||||
cout << "Enter separator >>>";
|
||||
getline(cin, sep, '\n');
|
||||
join(sep.c_str(), inf, fout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void join(const char *sep, istream &ist, ostream &ost) {
|
||||
while (!ist.eof() && ist.good()) {
|
||||
char buf[MAX_STRING];
|
||||
ist >> buf;
|
||||
ost << buf;
|
||||
if (!ist.eof()) {
|
||||
ost << sep;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue