cpp1.cpp
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main()
{
ifstream cinn(".in");
string str(1001,'\0');
char ch;
bool flg_chg=true;
int dlt_t;
str[0]=':';
while(true) {
if((cinn.peek())!=EOF) {
ch=cinn.get();
if(str[cinn.tellg()]!=ch) {
str[cinn.tellg()]=ch;
flg_chg=true;
}
}
else {
if(flg_chg) {
cout<<"[ str ] "<<str.c_str()<<endl;
flg_chg=false;
cout<<"[ tim ] : "<<(clock()-dlt_t)<<endl;
}
dlt_t=clock();
cinn.seekg(0);
Sleep(2);
}
}
return 0;
}
cpp2.cpp
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main()
{
ofstream coutt(".in");
string str;
int cnt=0;
char ch;
while(true) {
coutt<<cnt++<<" ";
if(coutt.tellp()>100) {
coutt.seekp(0);
Sleep(5);
}
}
return 0;
}