Click here to Skip to main content
16,007,277 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How can I change the ip configuration of the local host using vc? Pin
ian mariano3-Nov-02 23:42
ian mariano3-Nov-02 23:42 
GeneralThread in DLL Pin
stevenson3-Nov-02 15:04
stevenson3-Nov-02 15:04 
GeneralRe: Thread in DLL Pin
Le centriste3-Nov-02 16:43
Le centriste3-Nov-02 16:43 
GeneralRe: Thread in DLL Pin
stevenson3-Nov-02 19:06
stevenson3-Nov-02 19:06 
GeneralRe: Thread in DLL Pin
Paul M Watt3-Nov-02 19:49
mentorPaul M Watt3-Nov-02 19:49 
GeneralPointers, casting and volatile Pin
Jay23-Nov-02 13:55
Jay23-Nov-02 13:55 
GeneralRe: Pointers, casting and volatile Pin
Nick Parker3-Nov-02 15:51
protectorNick Parker3-Nov-02 15:51 
GeneralRe: Pointers, casting and volatile Pin
ian mariano3-Nov-02 15:57
ian mariano3-Nov-02 15:57 
Wow, you really have to work on formatting your code a little bit.

Your casts are odd as well and you'll have problems because strcmp expects strings to be NULL (0) terminated, you are better off using strncmp so you can set a max comparison size (in your case 100.) Also, what happens if fread reads less than 100 bytes or past the end of a either file? MSDN states "The file-pointer position is indeterminate if an error occurs. The value of a partially read item cannot be determined."

If you malloc you better free! You allocate memory, but then you do a return without ever freeing the memory, you also return without ever _closeing the file handles (or is this done somewhere else?)

Do you really need to use a void pointer? Take a look at the following example on MSDN: fread()[^]

If you just use a buffer of char, you should be on your way.

You should also check for end of files (using feof), and read errors (fread returning 0). Error handling is extremely important, and should never never never ever be omitted for production code (ever.) For illustrative purposes, many people do omit error handling, usually with a caveat that they've done so, or that the lack thereof is implied Cool | :cool:

Hopefully this will help you on your way.

"The greatest danger to humanity is humanity without an open mind."
  - Ian Mariano - http://www.ian-space.com/

GeneralRe: Pointers, casting and volatile Pin
Jay24-Nov-02 5:46
Jay24-Nov-02 5:46 
GeneralRe: Pointers, casting and volatile Pin
ian mariano4-Nov-02 6:54
ian mariano4-Nov-02 6:54 
GeneralRe: Pointers, casting and volatile Pin
Jay24-Nov-02 5:57
Jay24-Nov-02 5:57 
GeneralRe: Pointers, casting and volatile Pin
Christian Graus3-Nov-02 16:38
protectorChristian Graus3-Nov-02 16:38 
GeneralRe: Pointers, casting and volatile Pin
Jay24-Nov-02 5:27
Jay24-Nov-02 5:27 
GeneralRe: Pointers, casting and volatile Pin
Christian Graus4-Nov-02 11:28
protectorChristian Graus4-Nov-02 11:28 
QuestionHow to fully override a pop-up menu item? Pin
3-Nov-02 13:26
suss3-Nov-02 13:26 
GeneralWindows 98 Problems Pin
Swinefeaster3-Nov-02 11:15
Swinefeaster3-Nov-02 11:15 
GeneralRe: Windows 98 Problems Pin
Swinefeaster3-Nov-02 21:55
Swinefeaster3-Nov-02 21:55 
GeneralRe: Windows 98 Problems Pin
Christian Graus3-Nov-02 11:35
protectorChristian Graus3-Nov-02 11:35 
GeneralRe: Windows 98 Problems Pin
Swinefeaster3-Nov-02 21:53
Swinefeaster3-Nov-02 21:53 
GeneralRe: Windows 98 Problems Pin
Swinefeaster5-Nov-02 19:19
Swinefeaster5-Nov-02 19:19 
Generaldocument filter Pin
tom20003-Nov-02 10:26
tom20003-Nov-02 10:26 
GeneralRe: document filter Pin
Christian Graus3-Nov-02 11:36
protectorChristian Graus3-Nov-02 11:36 
GeneralRe: document filter Pin
Chris Richardson3-Nov-02 12:49
Chris Richardson3-Nov-02 12:49 
GeneralRe: document filter Pin
tom20003-Nov-02 15:28
tom20003-Nov-02 15:28 
GeneralRe: document filter Pin
Roger Allen3-Nov-02 23:59
Roger Allen3-Nov-02 23:59 

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.