#include<fstream>
#include<iostream>
#include<string>
using namespace std;
int main()
{
fstream out;
out.open("rpt1.txt", ios::out|ios::app); //以输入方式打开rpt1.txt 并且定位到文件尾部开始输入
int i = 0;
int j = 0;
out.seekp(0, ios::end); //定位到文件尾部
if (!out.is_open()) //检测是否打开
{
cout << "cannot open file" << endl;
return 0;
}
char t[20] = {'0'}; //初始化
char k = { '0' };//判断条件
string w;
while(1)
{
cout << "输入数据" << endl;
cin >> t;
if (t[19] != '\0')
{
//cout << "输入数据错误,请重新输入" << endl;
//memset(t,0,sizeof(t)); //初始化t
t[19] = '\0';
}
w.assign(t);
w = w + ' '+w; //以空格隔开 ,在文件中以两列数据写入
out << w.c_str()<<endl;
// cout << t << endl;
}
out.close();
return 0;
}