Click here to Skip to main content
16,019,244 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: stdin always the keyboard ? Pin
David Crow26-Nov-07 7:25
David Crow26-Nov-07 7:25 
GeneralRe: stdin always the keyboard ? Pin
Florin Crişan26-Nov-07 21:26
Florin Crişan26-Nov-07 21:26 
Questionfclose(f_ptr2) - "Access Violation or memery can not be read" Pin
mrby12326-Nov-07 6:07
mrby12326-Nov-07 6:07 
AnswerRe: fclose(f_ptr2) - "Access Violation or memery can not be read" Pin
Mark Salsbery26-Nov-07 6:15
Mark Salsbery26-Nov-07 6:15 
GeneralRe: fclose(f_ptr2) - "Access Violation or memery can not be read" Pin
mrby12326-Nov-07 6:32
mrby12326-Nov-07 6:32 
AnswerRe: fclose(f_ptr2) - "Access Violation or memery can not be read" Pin
Luc Pattyn26-Nov-07 6:33
sitebuilderLuc Pattyn26-Nov-07 6:33 
GeneralRe: fclose(f_ptr2) - "Access Violation or memery can not be read" Pin
mrby12326-Nov-07 6:52
mrby12326-Nov-07 6:52 
GeneralRe: fclose(f_ptr2) - "Access Violation or memery can not be read" [modified] Pin
Luc Pattyn26-Nov-07 7:03
sitebuilderLuc Pattyn26-Nov-07 7:03 
Hi,

[Added] ignore this reply, it is wrong! [/added]

there is a problem in fileName[i]=FindFileData.cFileName;

this line does NOT copy the filename, it copies the pointer to the cFileName field
in your unique FindFileData struct, hence in all iterations it will point to the
buffer containing the last data written into it.

If you want to hold all the different filenames, you must copy them, which you could
do with strcpy() or strncpy().

BTW: your NULL test shows a MessageBox but then continues the program execution,
which will result in failure of fscanf and/or fclose. The right way to handle this is
to have an if-then-else with all file actions (fscanf/fclose) in one part, and the
error handling (I do not really like MessageBox !) in the other part.

Smile | :)


-- modified at 13:39 Monday 26th November, 2007

Luc Pattyn [Forum Guidelines] [My Articles]


this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets


GeneralRe: fclose(f_ptr2) - "Access Violation or memery can not be read" Pin
David Crow26-Nov-07 7:22
David Crow26-Nov-07 7:22 
GeneralRe: fclose(f_ptr2) - "Access Violation or memery can not be read" Pin
Luc Pattyn26-Nov-07 7:39
sitebuilderLuc Pattyn26-Nov-07 7:39 
QuestionRe: fclose(f_ptr2) - "Access Violation or memery can not be read" Pin
David Crow26-Nov-07 7:18
David Crow26-Nov-07 7:18 
AnswerRe: fclose(f_ptr2) - "Access Violation or memery can not be read" Pin
Luc Pattyn26-Nov-07 7:48
sitebuilderLuc Pattyn26-Nov-07 7:48 
AnswerRe: fclose(f_ptr2) - "Access Violation or memery can not be read" Pin
mrby12326-Nov-07 8:12
mrby12326-Nov-07 8:12 
GeneralRe: fclose(f_ptr2) - "Access Violation or memery can not be read" Pin
David Crow26-Nov-07 10:37
David Crow26-Nov-07 10:37 
GeneralRe: fclose(f_ptr2) - "Access Violation or memery can not be read" Pin
Mark Salsbery26-Nov-07 13:23
Mark Salsbery26-Nov-07 13:23 
GeneralRe: fclose(f_ptr2) - "Access Violation or memery can not be read" Pin
David Crow26-Nov-07 15:46
David Crow26-Nov-07 15:46 
GeneralRe: fclose(f_ptr2) - "Access Violation or memery can not be read" Pin
Sunil Shindekar26-Nov-07 23:47
Sunil Shindekar26-Nov-07 23:47 
GeneralRe: fclose(f_ptr2) - "Access Violation or memery can not be read" Pin
David Crow27-Nov-07 3:46
David Crow27-Nov-07 3:46 
GeneralRe: fclose(f_ptr2) - "Access Violation or memery can not be read" Pin
Sunil Shindekar27-Nov-07 21:06
Sunil Shindekar27-Nov-07 21:06 
QuestionRe: fclose(f_ptr2) - "Access Violation or memery can not be read" Pin
David Crow28-Nov-07 2:32
David Crow28-Nov-07 2:32 
Questionfclose(f_ptr2) - "Access Violation or memery can not be read" Pin
mrby12326-Nov-07 5:59
mrby12326-Nov-07 5:59 
AnswerRe: fclose(f_ptr2) - "Access Violation or memery can not be read" Pin
Mark Salsbery26-Nov-07 6:05
Mark Salsbery26-Nov-07 6:05 
GeneralRe: fclose(f_ptr2) - "Access Violation or memery can not be read" Pin
mrby12326-Nov-07 6:36
mrby12326-Nov-07 6:36 
QuestionRe: fclose(f_ptr2) - "Access Violation or memery can not be read" Pin
David Crow26-Nov-07 7:12
David Crow26-Nov-07 7:12 
AnswerRe: fclose(f_ptr2) - "Access Violation or memery can not be read" Pin
mrby12326-Nov-07 7:30
mrby12326-Nov-07 7:30 

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.