Click here to Skip to main content
15,887,214 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: About strings in c language Pin
dusty_dex16-Apr-13 0:41
dusty_dex16-Apr-13 0:41 
GeneralRe: About strings in c language Pin
Richard MacCutchan16-Apr-13 3:41
mveRichard MacCutchan16-Apr-13 3:41 
GeneralRe: About strings in c language Pin
Erudite_Eric16-Apr-13 4:52
Erudite_Eric16-Apr-13 4:52 
GeneralRe: About strings in c language Pin
dusty_dex16-Apr-13 6:25
dusty_dex16-Apr-13 6:25 
GeneralRe: About strings in c language Pin
Erudite_Eric16-Apr-13 7:33
Erudite_Eric16-Apr-13 7:33 
GeneralRe: About strings in c language Pin
dusty_dex16-Apr-13 9:19
dusty_dex16-Apr-13 9:19 
AnswerRe: About strings in c language Pin
Erudite_Eric16-Apr-13 4:54
Erudite_Eric16-Apr-13 4:54 
GeneralRe: About strings in c language Pin
H.Brydon16-Apr-13 5:16
professionalH.Brydon16-Apr-13 5:16 
Erudite_Eric wrote:
char mystr[100];
 
memset(mystr, 0, 100); // not necessary but I like it tidy

strcpy(mystr, "ask a better question");

I have always held that less code is better code. When doing this kind of thing I prefer the syntax:

C++
char mystr[100] = {0};

strcpy(mystr, "ask a better question");

which I think is clearer and lets the compiler do all the work.

[Also I would use strcpy_s() and probably several other stylistic issues...]
--
Harvey

GeneralRe: About strings in c language Pin
Erudite_Eric16-Apr-13 7:32
Erudite_Eric16-Apr-13 7:32 
AnswerRe: About strings in c language Pin
Marco Bertschi17-Apr-13 1:46
protectorMarco Bertschi17-Apr-13 1:46 
QuestionUnable to read in edit control data Pin
ForNow15-Apr-13 3:46
ForNow15-Apr-13 3:46 
QuestionRe: Unable to read in edit control data Pin
David Crow15-Apr-13 3:55
David Crow15-Apr-13 3:55 
AnswerRe: Unable to read in edit control data Pin
ForNow15-Apr-13 4:44
ForNow15-Apr-13 4:44 
AnswerRe: Unable to read in edit control data Pin
H.Brydon15-Apr-13 17:44
professionalH.Brydon15-Apr-13 17:44 
AnswerRe: Unable to read in edit control data Pin
Richard MacCutchan15-Apr-13 4:33
mveRichard MacCutchan15-Apr-13 4:33 
GeneralRe: Unable to read in edit control data Pin
ForNow15-Apr-13 4:45
ForNow15-Apr-13 4:45 
GeneralRe: Unable to read in edit control data Pin
Richard MacCutchan15-Apr-13 5:41
mveRichard MacCutchan15-Apr-13 5:41 
GeneralRe: Unable to read in edit control data Pin
ForNow15-Apr-13 5:57
ForNow15-Apr-13 5:57 
GeneralRe: Unable to read in edit control data Pin
Richard MacCutchan15-Apr-13 6:53
mveRichard MacCutchan15-Apr-13 6:53 
GeneralRe: Unable to read in edit control data Pin
H.Brydon15-Apr-13 17:51
professionalH.Brydon15-Apr-13 17:51 
GeneralRe: Unable to read in edit control data Pin
H.Brydon15-Apr-13 17:47
professionalH.Brydon15-Apr-13 17:47 
GeneralRe: Unable to read in edit control data Pin
Richard MacCutchan15-Apr-13 21:01
mveRichard MacCutchan15-Apr-13 21:01 
GeneralRe: Unable to read in edit control data Pin
Orjan Westin15-Apr-13 22:47
professionalOrjan Westin15-Apr-13 22:47 
GeneralRe: Unable to read in edit control data Pin
Richard MacCutchan15-Apr-13 23:05
mveRichard MacCutchan15-Apr-13 23:05 
GeneralRe: Unable to read in edit control data Pin
Orjan Westin16-Apr-13 0:14
professionalOrjan Westin16-Apr-13 0:14 

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.