Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hi , little question please in codegear c++ builder

Status
Not open for further replies.

helleye

Programmer
Nov 25, 2007
2
IL

hi,
using vcl , and trying to use TstringList with ascii(1) as delimiter

TStringList * templist3 = new TStringList;
templist3->LoadFromFile("xxx.txt");
mylist = new TStringList;
mylist->Delimiter = static_cast<char>(1);
mylist->StrictDelimiter=TRUE;
mylist->DelimitedText=templist3->Text.c_str();

this code works fine and all is cool when program runs
problem is when i want to save all
tried

mylist->SaveToFile("xxx,txt");
this way i lost the ascii(1) to a later load :)

tried
for (int i = 0; i < mylist->Count; i++)
{
myfile << mylist->Strings.c_str();
myfile << static_cast<char>(1);
}
this way its adding lots of strange \n in the middle of everywhere

please help
thanks much in advance
 
The problem with using almost any character below ascii 32 (decimal) is the OS tends to interpret that character for a special meaning. For example, ascii(1) means start of header by the OS. If the OS doesn't recognize a valid header, it tosses the character.

I would suggest that you use something more standard like a comma (,) or even the vertical bar (|). If you MUST use ascii(1) then open your file in binary mode for both reading and writing.

James P. Cottingham
-----------------------------------------
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 

thanks

i dont think this is the problem

myfile << mylist->Strings.c_str();
this is the prolematic line , it put some \n where it wants
solved by a parser that removed those , ugly workaround :\

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top