Click here to Skip to main content
15,912,400 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: array of char-newbie Pin
toxcct12-Jun-06 5:20
toxcct12-Jun-06 5:20 
GeneralRe: array of char-newbie Pin
antonaras12-Jun-06 6:19
antonaras12-Jun-06 6:19 
GeneralRe: array of char-newbie Pin
toxcct12-Jun-06 6:24
toxcct12-Jun-06 6:24 
GeneralRe: array of char-newbie Pin
David Crow12-Jun-06 8:34
David Crow12-Jun-06 8:34 
AnswerRe: array of char-newbie Pin
Zac Howland12-Jun-06 5:29
Zac Howland12-Jun-06 5:29 
GeneralRe: array of char-newbie Pin
antonaras12-Jun-06 6:22
antonaras12-Jun-06 6:22 
GeneralRe: array of char-newbie Pin
Zac Howland12-Jun-06 6:32
Zac Howland12-Jun-06 6:32 
AnswerRe: array of char-newbie Pin
James R. Twine12-Jun-06 6:53
James R. Twine12-Jun-06 6:53 
   The standard string-handling functions like strcpy(...), strcat(...), sprintf(...), etc. will write a terminating NUL (not a NULL[^]) into the buffer you are using.

   So if you use them, you normally do not have to worry about previous data causing issues (unless you are concerned about security, but that is another issue).  Here is an example:
char caBuffer[ 50 ];
 
strcpy( caBuffer, "A Looooooooong String" );
strcpy( caBuffer, "A Short String" );
puts( caBuffer );
   After the first call to strcpy(..) the buffer will contain (NUL is represented by Ø):
0123456789012345678901</CODE>
<CODE>----------------------</CODE>
A Looooooooong String<CODE>Ø
   -and after the second call to strcpy(...), the buffer will likely contain:
0123456789012345678901</CODE>
<CODE>----------------------</CODE>
A Short String<CODE>Ø</CODE>String<CODE>Ø
   When the string is shown using puts(...), it will display A Short String, even though the actual memory for the buffer has the extra data in it.  Since string-handling functions use NUL as an end-of-string indicator, puts(...) stops when it gets to the first NUL it encounters.

   Peace!

-=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites
(Please rate this post!)
GeneralRe: array of char-newbie Pin
jhwurmbach21-Jun-06 22:01
jhwurmbach21-Jun-06 22:01 
JokeRe: array of char-newbie Pin
James R. Twine21-Jun-06 23:48
James R. Twine21-Jun-06 23:48 
GeneralRe: array of char-newbie Pin
Nish Nishant12-Jun-06 8:50
sitebuilderNish Nishant12-Jun-06 8:50 
GeneralRe: array of char-newbie Pin
Zac Howland12-Jun-06 10:41
Zac Howland12-Jun-06 10:41 
AnswerRe: array of char-newbie Pin
James R. Twine13-Jun-06 3:17
James R. Twine13-Jun-06 3:17 
GeneralRe: array of char-newbie Pin
Nish Nishant13-Jun-06 8:49
sitebuilderNish Nishant13-Jun-06 8:49 
GeneralRe: array of char-newbie Pin
James R. Twine13-Jun-06 15:39
James R. Twine13-Jun-06 15:39 
GeneralRe: array of char-newbie Pin
Zac Howland13-Jun-06 12:19
Zac Howland13-Jun-06 12:19 
GeneralRe: array of char-newbie Pin
antonaras12-Jun-06 21:39
antonaras12-Jun-06 21:39 
GeneralRe: array of char-newbie Pin
James R. Twine13-Jun-06 3:18
James R. Twine13-Jun-06 3:18 
QuestionGeneral question linking Fortran to C/C++ using MFC Pin
deltaseq012-Jun-06 4:56
deltaseq012-Jun-06 4:56 
AnswerRe: General question linking Fortran to C/C++ using MFC Pin
Zac Howland12-Jun-06 5:33
Zac Howland12-Jun-06 5:33 
GeneralRe: General question linking Fortran to C/C++ using MFC Pin
deltaseq012-Jun-06 6:29
deltaseq012-Jun-06 6:29 
GeneralRe: General question linking Fortran to C/C++ using MFC Pin
Chris Losinger12-Jun-06 6:36
professionalChris Losinger12-Jun-06 6:36 
GeneralRe: General question linking Fortran to C/C++ using MFC Pin
Zac Howland12-Jun-06 6:40
Zac Howland12-Jun-06 6:40 
GeneralRe: General question linking Fortran to C/C++ using MFC Pin
deltaseq012-Jun-06 7:39
deltaseq012-Jun-06 7:39 
Question::~AFX_MAINTAIN_STATE2 already defined Pin
simwall12-Jun-06 4:49
simwall12-Jun-06 4:49 

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.