Click here to Skip to main content
15,890,557 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Read a file on click event Pin
CodingLover16-Oct-07 18:09
CodingLover16-Oct-07 18:09 
GeneralRe: Read a file on click event Pin
David Crow17-Oct-07 4:02
David Crow17-Oct-07 4:02 
GeneralRe: Read a file on click event Pin
CodingLover18-Oct-07 20:16
CodingLover18-Oct-07 20:16 
AnswerRe: Read a file on click event Pin
Mark Salsbery16-Oct-07 6:20
Mark Salsbery16-Oct-07 6:20 
GeneralRe: Read a file on click event Pin
CodingLover16-Oct-07 19:11
CodingLover16-Oct-07 19:11 
GeneralRe: Read a file on click event Pin
chandu00416-Oct-07 20:58
chandu00416-Oct-07 20:58 
GeneralRe: Read a file on click event Pin
CodingLover16-Oct-07 21:08
CodingLover16-Oct-07 21:08 
GeneralRe: Read a file on click event Pin
Mark Salsbery17-Oct-07 5:21
Mark Salsbery17-Oct-07 5:21 
Eranga Thennakoon wrote:
But the following part is not clear, when I do it it wont print any value to the file. Just print an annoying character.

You missed my point entirely. 

You need some way to determine how long the string is. 
You can't just call strlen() on an uninitialized char array.

If the string is the entire file use chandu004's suggestion -
you can read it all in one shot.

Otherwise, you're going to need to learn about "strings"
(char arrays), files, etc. before you'll understand any of this.

I gave one example that writes the string length so you know how much
to read later.  Your CFile is in binary mode - I wrote binary data.
The "annoying character" was never meant to be a readable character.

If everything in the file needs to be text, you need to deal with that.
Whether you use endlines, carriage-return/linefeeed pairs, or some other
escape character to separate your strings is up to you.

Mark





Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

QuestionHow to access all the Editboxes in a form. Pin
Anand Todkar15-Oct-07 19:12
Anand Todkar15-Oct-07 19:12 
AnswerRe: How to access all the Editboxes in a form. Pin
Hamid_RT15-Oct-07 19:19
Hamid_RT15-Oct-07 19:19 
GeneralRe: How to access all the Editboxes in a form. Pin
Anand Todkar15-Oct-07 19:24
Anand Todkar15-Oct-07 19:24 
GeneralRe: How to access all the Editboxes in a form. Pin
Naveen15-Oct-07 19:28
Naveen15-Oct-07 19:28 
QuestionRe: How to access all the Editboxes in a form. Pin
David Crow16-Oct-07 2:23
David Crow16-Oct-07 2:23 
AnswerRe: How to access all the Editboxes in a form. Pin
Anand Todkar16-Oct-07 2:34
Anand Todkar16-Oct-07 2:34 
GeneralRe: How to access all the Editboxes in a form. Pin
CodingLover15-Oct-07 19:26
CodingLover15-Oct-07 19:26 
GeneralRe: How to access all the Editboxes in a form. Pin
Hamid_RT15-Oct-07 19:38
Hamid_RT15-Oct-07 19:38 
GeneralRe: How to access all the Editboxes in a form. Pin
CodingLover15-Oct-07 19:47
CodingLover15-Oct-07 19:47 
AnswerRe: How to access all the Editboxes in a form. Pin
Naveen15-Oct-07 19:25
Naveen15-Oct-07 19:25 
GeneralRe: How to access all the Editboxes in a form. Pin
Anand Todkar15-Oct-07 19:31
Anand Todkar15-Oct-07 19:31 
AnswerRe: How to access all the Editboxes in a form. Pin
Nelek15-Oct-07 21:03
protectorNelek15-Oct-07 21:03 
QuestionList iteration Problem [modified] Pin
ashishbhatt15-Oct-07 19:04
ashishbhatt15-Oct-07 19:04 
AnswerRe: List iteration Problem Pin
zakkas248315-Oct-07 20:11
zakkas248315-Oct-07 20:11 
GeneralRe: List iteration Problem Pin
ashishbhatt15-Oct-07 20:29
ashishbhatt15-Oct-07 20:29 
GeneralRe: List iteration Problem Pin
Nelek15-Oct-07 21:05
protectorNelek15-Oct-07 21:05 
GeneralRe: List iteration Problem Pin
zakkas248315-Oct-07 21:38
zakkas248315-Oct-07 21:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.