Click here to Skip to main content
15,884,099 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Anything wrong Pin
CPallini31-Mar-11 8:02
mveCPallini31-Mar-11 8:02 
GeneralRe: Anything wrong Pin
Luc Pattyn31-Mar-11 8:09
sitebuilderLuc Pattyn31-Mar-11 8:09 
GeneralRe: Anything wrong Pin
CPallini31-Mar-11 8:17
mveCPallini31-Mar-11 8:17 
AnswerRe: Anything wrong Pin
CPallini31-Mar-11 5:44
mveCPallini31-Mar-11 5:44 
GeneralRe: Anything wrong Pin
Smith#31-Mar-11 5:52
Smith#31-Mar-11 5:52 
GeneralRe: Anything wrong Pin
Waldermort31-Mar-11 6:14
Waldermort31-Mar-11 6:14 
GeneralRe: Anything wrong Pin
Smith#31-Mar-11 6:22
Smith#31-Mar-11 6:22 
GeneralRe: Anything wrong Pin
Waldermort31-Mar-11 6:35
Waldermort31-Mar-11 6:35 
No. When dealing with string buffers you only need to set the first char/wchar/tchar to 0.

char myString[100]; // Is a buffer of 100 chars the a string may be copied into.<br />
strcat( myString, "Hello World!" ); // will fail because the buffer is full of junk.<br />
// but<br />
strcpy( myString, "World!" ); // will work because it doesn't care what is in the buffer<br />
myString[0] = 0; // copies an empty string to the buffer<br />
strcat( myString, "Hello World!" ); // appends the string to the empty string ( also sets the character after '!' to \0 or NULL.


The new string is actually 13 chars because there is a 0 at the end.

On another note. You shouldn't be using those string functions. There are safer versions available:
strcpy_s( myString, 100, "Hello World!" );
These check to make sure the buffer is large enough for the string

Also, you might want to read up on TCHAR and the unicode/ansi string functions
TCHAR myString[100];<br />
_tcscpy_s( myString, 100, _T("Hello World!");

Waldermort

GeneralRe: Anything wrong Pin
Luc Pattyn31-Mar-11 7:18
sitebuilderLuc Pattyn31-Mar-11 7:18 
GeneralRe: Anything wrong Pin
CPallini31-Mar-11 7:36
mveCPallini31-Mar-11 7:36 
GeneralRe: Anything wrong Pin
Luc Pattyn31-Mar-11 7:39
sitebuilderLuc Pattyn31-Mar-11 7:39 
GeneralRe: Anything wrong Pin
CPallini31-Mar-11 8:02
mveCPallini31-Mar-11 8:02 
QuestionCompare And Set 64 bit Pin
Waldermort31-Mar-11 1:40
Waldermort31-Mar-11 1:40 
AnswerRe: Compare And Set 64 bit Pin
Klaus-Werner Konrad31-Mar-11 9:06
Klaus-Werner Konrad31-Mar-11 9:06 
QuestionNeed help on windows socket programming Pin
John50231-Mar-11 0:30
John50231-Mar-11 0:30 
AnswerRe: Need help on windows socket programming Pin
Nelek31-Mar-11 0:33
protectorNelek31-Mar-11 0:33 
AnswerRe: Need help on windows socket programming Pin
Dave Calkins31-Mar-11 6:28
Dave Calkins31-Mar-11 6:28 
QuestionVC 6 bug? Pin
includeh1030-Mar-11 16:01
includeh1030-Mar-11 16:01 
AnswerRe: VC 6 bug? Pin
Albert Holguin30-Mar-11 17:10
professionalAlbert Holguin30-Mar-11 17:10 
AnswerRe: VC 6 bug? Pin
_Flaviu30-Mar-11 21:17
_Flaviu30-Mar-11 21:17 
AnswerRe: VC 6 bug? Pin
Hans Dietrich30-Mar-11 22:20
mentorHans Dietrich30-Mar-11 22:20 
AnswerRe: VC 6 bug? Pin
CPallini30-Mar-11 22:29
mveCPallini30-Mar-11 22:29 
AnswerRe: VC 6 bug? Pin
Nyil31-Mar-11 1:34
Nyil31-Mar-11 1:34 
AnswerRe: VC 6 bug? Pin
Smith#31-Mar-11 5:12
Smith#31-Mar-11 5:12 
Questioninvisible the file or folder Pin
sarfaraznawaz30-Mar-11 5:15
sarfaraznawaz30-Mar-11 5:15 

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.