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

C / C++ / MFC

 
AnswerRe: array of char-newbie Pin
Justin Tay12-Jun-06 5:08
Justin Tay12-Jun-06 5:08 
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 
If you are reading in character buffers as a whole, yes, you will have a problem. If you are using them as C-style strings, then no, you won't. The reasoning is that C-style strings have a null-terminator.

Example:
const unsigned int ARRAY_SIZE = 20;<br />
char myBuffer[ARRAY_SIZE] = {0};<br />
<br />
// Right now, the entire buffer is 0's<br />
strcpy(myBuffer, "My funny String");<br />
<br />
cout << myBuffer << endl;<br />
cout << strlen(myBuffer) << endl;<br />
// Output will be:<br />
// My funny String<br />
// 15<br />
<br />
// Now, replace the buffer<br />
strcpy(myBuffer, "Hello");<br />
<br />
cout << myBuffer << endl;<br />
cout << strlen(myBuffer) << endl;<br />
// Output will be:<br />
// Hello<br />
// 5


The only time you would run into problems doing this is when you will be looking at the entire character buffer (so all 20 characters) for information. However, in that case, you most likely will not be treating the buffer as a string, and will not be using the strXXX family of functions on it either (or their _tsc equivalents).

If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week

Zac
AnswerRe: array of char-newbie Pin
James R. Twine12-Jun-06 6:53
James R. Twine12-Jun-06 6:53 
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 

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.