Thread: Writing "Enter" character to a txt file

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    105

    Writing "Enter" character to a txt file

    Greetings!

    Now I am at writing into a file. My file is a simple plain text file, with ".dat" extension. There's only one problem with it.

    I cannot make a new line in the file. I use the "\r\n" character as the ending of a line. But instead of writing the following data into the next line, it writes only small squares (special character) into the file.
    How can I make a new line?

    Thanks for the help again, and this time there's no poll
    Han

  2. #2
    Registered User
    Join Date
    Dec 2002
    Posts
    221
    show the code please

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    105
    I hope this time I use the code tag properly...

    Code:
       iFileHandle = FileOpen(fajlnev, fmOpenWrite);
        iFileLength = FileSeek(iFileHandle,0,2);
    //Megadom, hogy mit kell kiírni
        kiirando="Csoport azonosító:," + txtCsoportID->Text + char(13);
        kiirando=kiirando + "Előkezelés:," + txtElokezeles->Text + char(13);
        kiirando=kiirando + "Előkezelési dózis:," + txtElodozis->Text + char(13);
        kiirando=kiirando + "Előkezelés időtartama:," + txtEloido->Text + char(13);
        kiirando=kiirando + "Kezelés:," + txtKezeles->Text + char(13);
        kiirando=kiirando + "Kezelési dózis:," + txtKezdozis->Text + char(13);
        kiirando=kiirando + "Kezelés időtartama:," + txtKezido->Text + char(13) + char(13)+ char(13);
        FileSeek(iFileHandle,0,0);
    //Kiírom a fileba az adatokat
        int tempint=kiirando.Length()+1;
        pszBuffer = new char[tempint];
        for (int i=1; i< tempint; i++)
             { pszBuffer[i-1]=kiirando[i]; };
        FileWrite(iFileHandle, pszBuffer,kiirando.Length());
        FileClose(iFileHandle);
         }
    This is the code. After this I make a small exception handling, nothing serious.
    I use char(13) as the enter character here. The weird thing is that the Lister of Total Commander DOES recognize this as an Enter, but the Notepad doesn't.

    Thx
    Han
    Last edited by Hankyaku; 04-08-2003 at 11:08 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  3. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  4. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM