Click here to Skip to main content
16,006,442 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Breakpoint problem----howto use it in a loop Pin
James R. Twine28-Dec-01 7:09
James R. Twine28-Dec-01 7:09 
GeneralRe: Breakpoint problem----howto use it in a loop Pin
Todd Smith28-Dec-01 13:34
Todd Smith28-Dec-01 13:34 
GeneralRe: Breakpoint problem----howto use it in a loop Pin
Nemanja Trifunovic28-Dec-01 7:15
Nemanja Trifunovic28-Dec-01 7:15 
GeneralGetDeviceCaps problems... Pin
Braulio Dez28-Dec-01 6:05
Braulio Dez28-Dec-01 6:05 
GeneralLoading a string from a binary file Pin
James Bird28-Dec-01 5:34
James Bird28-Dec-01 5:34 
GeneralRe: Loading a string from a binary file Pin
Nemanja Trifunovic28-Dec-01 5:44
Nemanja Trifunovic28-Dec-01 5:44 
GeneralRe: Loading a string from a binary file Pin
Daniel Lohmann28-Dec-01 5:53
Daniel Lohmann28-Dec-01 5:53 
GeneralRe: Loading a string from a binary file Pin
James R. Twine28-Dec-01 7:06
James R. Twine28-Dec-01 7:06 
   You problem is two-fold.

   The first problem was already mentioned: your use of "==" will compare two pointers, not test for equality between two strings.

   The second problem (garbage characters) stems from the fact that C-Style character strings are normally terminated with a NUL (not NULL) character.  That NUL character tells whatever routine is manipulating the string where the end of the string is.  You will see garbage characters after your read in your 9 characters because whatever is displaying the string is going to keep showing characters until it finds the terminating NUL.

   While you do not need to write out the terminating NUL character when you write the string to a file (text or binary), you need to have that NUL there after you read it in (you can manually place it in the buffer) in order to have it treated as a C-Style string.  That is basically what you did when you had
szTest[9] = NULL
in your code.

   (BTW: Your code writes the NULL/NUL off the end of the allocated array. Character arrays that are going to contain C-Style strings should always 1 be character larger than the maximum length of the string.)

   Peace!

-=- James.
GeneralTrying to get the size of A3... Pin
Braulio Dez28-Dec-01 4:35
Braulio Dez28-Dec-01 4:35 
GeneralRotating shapes Pin
bhat_adarsh28-Dec-01 4:24
bhat_adarsh28-Dec-01 4:24 
GeneralRe: Rotating shapes Pin
567890123430-Dec-01 1:08
567890123430-Dec-01 1:08 
GeneralMigrating from Win9x to Linux - PLEASE HELP! Pin
Sergei Yevseyev28-Dec-01 4:16
Sergei Yevseyev28-Dec-01 4:16 
GeneralRe: Migrating from Win9x to Linux - PLEASE HELP! Pin
Matt Newman28-Dec-01 4:31
Matt Newman28-Dec-01 4:31 
GeneralRe: Migrating from Win9x to Linux - PLEASE HELP! Pin
Nemanja Trifunovic28-Dec-01 5:25
Nemanja Trifunovic28-Dec-01 5:25 
GeneralRe: Migrating from Win9x to Linux - PLEASE HELP! Pin
Fazlul Kabir28-Dec-01 5:30
Fazlul Kabir28-Dec-01 5:30 
GeneralRe: Migrating from Win9x to Linux - PLEASE HELP! Pin
Ravi Bhavnani28-Dec-01 5:31
professionalRavi Bhavnani28-Dec-01 5:31 
GeneralRe: Migrating from Win9x to Linux - PLEASE HELP! Pin
Tomasso7-Jan-02 7:10
Tomasso7-Jan-02 7:10 
Generalaccess CRecordSet from another class Pin
jafrazee28-Dec-01 2:43
jafrazee28-Dec-01 2:43 
GeneralRe: access CRecordSet from another class Pin
Carlos Antollini28-Dec-01 3:05
Carlos Antollini28-Dec-01 3:05 
GeneralRe: access CRecordSet from another class Pin
jafrazee28-Dec-01 3:46
jafrazee28-Dec-01 3:46 
GeneralRe: access CRecordSet from another class Pin
Carlos Antollini28-Dec-01 5:07
Carlos Antollini28-Dec-01 5:07 
Questionhow can i DRAW in CVIEW:OnInitialUpdate() function? Pin
AnonymousBabe@usa.net28-Dec-01 2:08
AnonymousBabe@usa.net28-Dec-01 2:08 
AnswerRe: how can i DRAW in CVIEW:OnInitialUpdate() function? Pin
AnonymousBabe@usa.net28-Dec-01 6:07
AnonymousBabe@usa.net28-Dec-01 6:07 
AnswerRe: how can i DRAW in CVIEW:OnInitialUpdate() function? Pin
Shog928-Dec-01 8:58
sitebuilderShog928-Dec-01 8:58 
GeneralRe: how can i DRAW in CVIEW:OnInitialUpdate() function? Pin
AnonymousBabe@usa.net28-Dec-01 14:23
AnonymousBabe@usa.net28-Dec-01 14:23 

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.