我的代码是这样的:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
char *buf=new char[Edit1->Text.Length()+Edit2->Text.Length()
+ComboBox1->Text.Length()+1];
StrCopy(buf,Edit1->Text.c_str());
strcat(buf,Edit2->Text.c_str());
//buf=buf+' ';
strcat(buf,ComboBox1->Text.c_str());
strcat(buf,"/n"
;
int texthandle=FileOpen("c://1.txt",fmOpenReadWrite);
if (!FileExists("c://1.txt"
)
texthandle=FileCreate("c://1.txt"
;
FileSeek(texthandle,0,2);
FileWrite(texthandle,buf,strlen(buf));
FileClose(texthandle);
delete [] buf;
}
能实现追加,但格式不对,显示格式如下:
a24男b23女c24男
目标格式是:
a 24 男
b 23 女
c 24 男