每秒向TXT文件写入字符串 追加200分

来源:百度知道 编辑:UC知道 时间:2024/06/01 14:46:33
直接给出 可以编译的代码 我是初学者 请详细告诉我
很简单
程序打开后自动在程序目录下 生成1.TXT 然后每秒向1.TXT文件 每行写入123

1.TXT 文本打开后是这样的 每行一个123 我编译正确 追200分
123
123
123
123
123
123
123
123
123
123
123
123
123
123
123
不管是什么语言 首选VC 我机上还有DELPHI 和VB 能实现的 直接给我代码

#include<fstream>
#include <iostream>
#include <windows.h>
using namespace std;

//c++程序,我编译可以实现

void main()
{

ofstream outfile ("1.txt",ios::out|ios::trunc);
if(!outfile){cerr<<"error";exit(1);};
outfile.close();

ofstream outfile1 ("1.txt",ios::out|ios::app);
if(!outfile1){cerr<<"error";exit(1);};
int order;
cout<<"输入时间长度[?]秒"<<endl;
cin>>order;
for (int i=0;i<order;i++)
{outfile1<<123<<" "<<endl;Sleep(1000);}
outfile1.close();
}

#include <Windows.h>
#include <stdio.h>

void WriteString ()
{
FILE *p= fopen("1.txt","a+");
fwrite("123\r\n",1,strlen("123\r\n"),p);
fclose(p);
}

int main( int argc, char * a