CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2006
    Posts
    55

    Exclamation Writing to flat text file w/o serialization

    Im trying to write some data to a text file. The text file would contain the logs & various data. Am using ofstream & whenever I write any datatype CString or LONG or anything, it writes in serialised form i guess.

    I try to write as: tofile<<strValue;

    But this is written to the file as some junk value. I want the text file to be readable when opened in notepad. I dont want to open the file from the application, and read those value, hence dont need serialization. How do i do?

  2. #2
    Join Date
    Oct 2000
    Location
    India
    Posts
    4,620

    Thumbs up Re: Writing to flat text file w/o serialization

    Hi,

    In your case, why do u need serialization ? You can just remove that code
    and use CFile or CStdioFile to write and read your data directly.
    All luck and have a great day.

    Regards,
    V.Girish

    Visit www.geocities.com/contactgirish for Source code, Tutorials, FAQs and Downloads.

  3. #3
    Join Date
    Oct 2000
    Location
    India
    Posts
    4,620

    Thumbs up Re: Writing to flat text file w/o serialization

    Hi,

    Alternatively, you can use CArchive::WriteString. Take a look at http://msdn2.microsoft.com/en-us/library/0ck300ac.aspx
    for a sample.
    All luck and have a great day.

    Regards,
    V.Girish

    Visit www.geocities.com/contactgirish for Source code, Tutorials, FAQs and Downloads.

  4. #4
    Join Date
    Jul 2006
    Posts
    55

    Re: Writing to flat text file w/o serialization

    Thanks! It helped.. :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured