I am using Embarcadero C++Builder XE and I am trying to write 123456 to a textfile like this:
String teststring = "123456";
int iFileHandle = FileCreate("example.txt");
int iLength = teststring.Length()*sizeof(wchar_t);
int output = FileWrite(iFileHandle, teststring.w_str(), iLength);
But the output is this:
1 2 3 4 5 6
Spaces have been added after every character. I can see that iLength is 12 so are the spaces added when the string is created and how can I prevent this?
You could just uses a string list and add the string you want to then then save the string list to file.
TStringList *Temp = new TStringList( );
Temp->Add("123456");
Temp->SaveToFile(("example.txt");
delete Temp;