Results 1 to 6 of 6

Thread: "new line break in readin' from file"

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2002
    Location
    in e middle of nowhere..
    Posts
    40

    Unhappy "new line break in readin' from file"

    hello there!!
    when i read from txt file and display out in the multiline edit box, they all read the new line break as "|", one dark stroke...
    i'm wondering how i can get rid of this,,,,

    i'm using MFC Dialog boxes,,,,,, btw.....

    and also,, doez anybody know what's the use of Tab control that we all c on the toolbar????
    dunno how to place items on it,,,, =~(


    thanks a lot!!!


  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Do you use MFC's CStdioFile class to read the file? With type set to CFile::modeText ?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2002
    Location
    in e middle of nowhere..
    Posts
    40

    Talking

    huh?? how??
    hee i juz used the codes i use for writing C programs...
    fread,, fopen,, all those,,,,,,,
    can explain to me how to use that???
    n some sample codes pls,,, hehe..... =)

    thank u.....


  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    CStdioFile is just a wrapper around those.

    Since you're reading a text file, you don't want the binary fread and fwrite, but rather the text io fgets, fputs, fprintf and fscanf.
    Open the file with
    fopen(filename, "?t");
    where ? is the access you want (r,a,w,r+,a+,w+).
    Then you can use the 4 functions, look them up in the reference.

    The C++ file streams can handle text files too. Don't pass the ios_base::binary flag to open and you'll be fine.

    Windows files can't handle text files correctly - they will not convert \r\n to \n. Neither does MFC CFile, which is just a wrapper around windows files.

    This is why there is the CStdioFile class. Derived from CFile, this class doesn't use windows files but rather C files. You can pass CFile::modeText to Open in order to open a file in text mode. Then you can call ReadString or WriteString for i/o.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Member
    Join Date
    Sep 2002
    Location
    in e middle of nowhere..
    Posts
    40
    thanks a lot!!!
    i'l try it out tnite.......

  6. #6

    Thread Starter
    Member
    Join Date
    Sep 2002
    Location
    in e middle of nowhere..
    Posts
    40

    Lightbulb

    hi.. thanks...now i can read from text file and display out nicely..
    but .. if i just want t scan part of it by passing the parameters, how can i do it???

    this is how my program is like..
    i choose from the list box, and according to the choice,, i want t display the respective information in the edit box....which will be read from txt file...

    so i need to pass some info so tat it can go and retrieve the correct part of txt file.....

    and now i hav 2 txt file,, 1 is for the list of choices i mentioned above for the list box,, and e other for e details....
    if i want t combine these 2 and retrieve accordingly, how shal i code it??

    thanks a lot....


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