Click here to Skip to main content
15,888,521 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to change the Color Palatte of Gif File. Pin
pubududilena6-Jul-04 17:45
pubududilena6-Jul-04 17:45 
Generalhelp with windows messages for ending a process Pin
AmericanBacon6-Jul-04 17:28
AmericanBacon6-Jul-04 17:28 
GeneralRe: help with windows messages for ending a process Pin
Ryan Binns6-Jul-04 18:22
Ryan Binns6-Jul-04 18:22 
GeneralNeed help! LoadImage took 30 seconds to load an icon Pin
Neil Yao6-Jul-04 17:16
Neil Yao6-Jul-04 17:16 
GeneralRe: Need help! LoadImage took 30 seconds to load an icon Pin
Johan Rosengren6-Jul-04 21:19
Johan Rosengren6-Jul-04 21:19 
GeneralStructur Read/Write From a File Pin
lewislewis_lewis6-Jul-04 17:04
lewislewis_lewis6-Jul-04 17:04 
GeneralRe: Structur Read/Write From a File Pin
Christian Graus6-Jul-04 17:08
protectorChristian Graus6-Jul-04 17:08 
GeneralRe: Structur Read/Write From a File Pin
#realJSOP7-Jul-04 3:22
mve#realJSOP7-Jul-04 3:22 
I believe he asked if he could do it that way, not a better way to do it.

Try this way...

<br />
#include "stdio.h" // replace quotes with pointy brackets in your code<br />
<br />
struct XYZSTRUCT<br />
{<br />
   int n1;<br />
   double d1;<br />
   char c[25];<br />
};<br />
<br />
XYZSTRUCT xyzItem;<br />
int nItemsRead = 0;<br />
<br />
FILE* f = fopen("MyFile.xyz", "rb");<br />
if (f)<br />
{<br />
   itemsRead = fread(&xyzItem, sizeof(XYZSTRUCT), 1, f);<br />
   fclose(f);<br />
}<br />
if (itemsRead < 1)<br />
{<br />
   // handle error here<br />
}<br />


Of course, Christian might be right about his claim that IOstreams are better, but sometimes, something quick and dirty like this are called for.

Keep in mind that you should stick with standard C++ types and not use MFC types when you're doing it this way.


------- sig starts

"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt

"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
QuestionHow to know the previous function from stack.. Pin
TssPrasad6-Jul-04 16:55
sussTssPrasad6-Jul-04 16:55 
AnswerRe: How to know the previous function from stack.. Pin
Christian Graus6-Jul-04 17:05
protectorChristian Graus6-Jul-04 17:05 
AnswerRe: How to know the previous function from stack.. Pin
parths6-Jul-04 21:37
parths6-Jul-04 21:37 
AnswerRe: How to know the previous function from stack.. Pin
David Crow7-Jul-04 3:32
David Crow7-Jul-04 3:32 
GeneralHelp Thread Process and Window Pin
phamdoan6-Jul-04 16:49
phamdoan6-Jul-04 16:49 
GeneralEnumThreadWindows Function Pin
Blake Miller7-Jul-04 5:02
Blake Miller7-Jul-04 5:02 
GeneralDumb RichEditView Question Pin
merkit6-Jul-04 16:28
merkit6-Jul-04 16:28 
GeneralRe: Dumb RichEditView Question Pin
David Crow7-Jul-04 3:33
David Crow7-Jul-04 3:33 
GeneralCheckRadioButton makes recursive calls Pin
elephantstar6-Jul-04 13:57
elephantstar6-Jul-04 13:57 
GeneralRe: CheckRadioButton makes recursive calls Pin
David Crow7-Jul-04 3:54
David Crow7-Jul-04 3:54 
GeneralRe: CheckRadioButton makes recursive calls Pin
elephantstar7-Jul-04 9:41
elephantstar7-Jul-04 9:41 
GeneralRe: CheckRadioButton makes recursive calls Pin
David Crow7-Jul-04 10:01
David Crow7-Jul-04 10:01 
GeneralRe: CheckRadioButton makes recursive calls Pin
elephantstar7-Jul-04 11:55
elephantstar7-Jul-04 11:55 
GeneralRe: CheckRadioButton makes recursive calls Pin
Blake Miller7-Jul-04 5:11
Blake Miller7-Jul-04 5:11 
GeneralRe: CheckRadioButton makes recursive calls Pin
elephantstar7-Jul-04 9:48
elephantstar7-Jul-04 9:48 
GeneralRe: CheckRadioButton makes recursive calls Pin
Blake Miller7-Jul-04 11:38
Blake Miller7-Jul-04 11:38 
GeneralRe: CheckRadioButton makes recursive calls Pin
elephantstar7-Jul-04 12:40
elephantstar7-Jul-04 12:40 

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.