Click here to Skip to main content
15,896,063 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Form View Splitter Pin
DarrollWalsh30-Sep-02 21:27
DarrollWalsh30-Sep-02 21:27 
GeneralAnother map question Pin
ns30-Sep-02 9:19
ns30-Sep-02 9:19 
GeneralRe: Another map question Pin
Chad Koehler30-Sep-02 9:29
Chad Koehler30-Sep-02 9:29 
Generalgreat news!! Pin
ns30-Sep-02 9:49
ns30-Sep-02 9:49 
GeneralWhat about read? Pin
ns30-Sep-02 10:00
ns30-Sep-02 10:00 
GeneralRe: What about read? Pin
Scott H. Settlemier30-Sep-02 10:14
Scott H. Settlemier30-Sep-02 10:14 
GeneralRe: What about read? Pin
ns30-Sep-02 10:21
ns30-Sep-02 10:21 
GeneralRe: What about read? Pin
Scott H. Settlemier1-Oct-02 7:36
Scott H. Settlemier1-Oct-02 7:36 
Argh. I can't stand it any longer.
Just leaving with a note that the above
is "icky" wont make the itch go away.
I wrote something knowingly bad above. Blush | :O

This may be pedantic but I gotta get rid of the itch. Smile | :)

GetBuffer returns a pointer to a buffer to which you may
safely store directly into the CString object, but using
a CString whose length happens to match the amount of
data you are reading in is just bad practice.

If one knows the amount of data to be read, then one
should specify it explicitly. e.g.

int n=128; // 128 byte field for planet name<br />
CString Planet;<br />
// read all 128 bytes and set CString to just the 0-terminated portion<br />
Planet.ReleaseBuffer(File.Read(Planet.GetBuffer(n),n)!=n?0:-1);


Better yet, create structures that mirror the fixed length
portions of the file and read them in entirety. e.g.

struct Names<br />
{<br />
   enum {NAMESIZE=128};<br />
   char  Planet[NAMESIZE];<br />
   char  System[NAMESIZE];<br />
   // etc.<br />
};<br />
<br />
ABC MyNames;<br />
VERIFY(File.Read(&MyNames,sizeof(MyNames))==sizeof(MyNames));


and if you need it in a CString later:
MyNames.Planet[NAMESIZE-1]=0; // make sure 0-terminated<br />
CString S=MyNames.Planet;

GeneralRe: What about read? Pin
ns1-Oct-02 7:40
ns1-Oct-02 7:40 
Generala map question Pin
ns30-Sep-02 8:57
ns30-Sep-02 8:57 
GeneralRe: a map question Pin
Anonymous30-Sep-02 9:20
Anonymous30-Sep-02 9:20 
GeneralRe: a map question Pin
RedZenBird30-Sep-02 12:16
RedZenBird30-Sep-02 12:16 
GeneralRe: a map question Pin
jhwurmbach30-Sep-02 21:49
jhwurmbach30-Sep-02 21:49 
GeneralRe: a map question Pin
ns1-Oct-02 2:26
ns1-Oct-02 2:26 
GeneralCreate array of CArray Pin
ooosawaddee330-Sep-02 7:29
ooosawaddee330-Sep-02 7:29 
GeneralRe: Create array of CArray Pin
jmkhael30-Sep-02 7:30
jmkhael30-Sep-02 7:30 
GeneralCfile and consecutive writes Pin
ns30-Sep-02 7:18
ns30-Sep-02 7:18 
GeneralRe: Cfile and consecutive writes Pin
jmkhael30-Sep-02 7:21
jmkhael30-Sep-02 7:21 
GeneralRe: Cfile and consecutive writes Pin
ns30-Sep-02 7:28
ns30-Sep-02 7:28 
GeneralRe: Cfile and consecutive writes Pin
jmkhael30-Sep-02 7:33
jmkhael30-Sep-02 7:33 
QuestionCan anyone help... Pin
Kash30-Sep-02 7:06
Kash30-Sep-02 7:06 
AnswerRe: Can anyone help... Pin
gije30-Sep-02 7:30
gije30-Sep-02 7:30 
GeneralRe: Can anyone help... Pin
Kash30-Sep-02 7:29
Kash30-Sep-02 7:29 
AnswerRe: Can anyone help... Pin
jmkhael30-Sep-02 7:54
jmkhael30-Sep-02 7:54 
GeneralRe: Can anyone help... Pin
Kash30-Sep-02 8:11
Kash30-Sep-02 8:11 

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.