Click here to Skip to main content
15,914,066 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionTrayClock??? Pin
kekeguo17-Jul-02 8:12
kekeguo17-Jul-02 8:12 
GeneralQuestion about sequence of events Pin
ns17-Jul-02 8:12
ns17-Jul-02 8:12 
GeneralRe: Question about sequence of events Pin
Ravi Bhavnani17-Jul-02 9:07
professionalRavi Bhavnani17-Jul-02 9:07 
GeneralWoW! Most excellent! Pin
ns17-Jul-02 9:10
ns17-Jul-02 9:10 
GeneralRe: WoW! Most excellent! Pin
Ravi Bhavnani17-Jul-02 9:31
professionalRavi Bhavnani17-Jul-02 9:31 
Generalstring initialization problem Pin
ChiYung17-Jul-02 8:07
ChiYung17-Jul-02 8:07 
GeneralRe: string initialization problem Pin
Joaquín M López Muñoz17-Jul-02 8:16
Joaquín M López Muñoz17-Jul-02 8:16 
GeneralRe: string initialization problem Pin
Nathan Blomquist17-Jul-02 8:17
Nathan Blomquist17-Jul-02 8:17 
ChiYung wrote:
strcpy(buffer, "");
buffer[0] = 'X';
cout << buffer << endl;


strcpy does not delete or null any of the characters inside of the buffer. Therefore passing in an empty string copies zero (0) characters and leaves the string untouched. If you want the string to be only 'X' you need to do something like:

buffer[0] = 'X';
buffer[1] = '\0';

The second character is the null character (the slash means it is an escape character); which in C means the end of the string. Character strings in C are always string length + 1. Example:

The string literal, "Hello World!", is actually 13 characters long, the 12 visible characters plus 1 for the null.

Hope this helps,
Nathan

---------------------------
Hmmm... what's a signature?
GeneralRe: string initialization problem Pin
jmkhael17-Jul-02 10:25
jmkhael17-Jul-02 10:25 
GeneralRe: string initialization problem Pin
Michael Dunn17-Jul-02 16:49
sitebuilderMichael Dunn17-Jul-02 16:49 
GeneralRe: string initialization problem Pin
Anonymous18-Jul-02 1:37
Anonymous18-Jul-02 1:37 
GeneralNT Service networking Pin
Greven17-Jul-02 8:01
Greven17-Jul-02 8:01 
GeneralRe: NT Service networking Pin
Daniel Lohmann17-Jul-02 14:09
Daniel Lohmann17-Jul-02 14:09 
GeneralRe: NT Service networking Pin
Greven17-Jul-02 14:52
Greven17-Jul-02 14:52 
GeneralRe: NT Service networking Pin
Daniel Lohmann17-Jul-02 21:02
Daniel Lohmann17-Jul-02 21:02 
Generaldisable keys in word document Pin
Srini Kella17-Jul-02 7:38
Srini Kella17-Jul-02 7:38 
GeneralRe: disable keys in word document Pin
Nick Parker17-Jul-02 8:13
protectorNick Parker17-Jul-02 8:13 
Generalmodifymenu question -about adding item Pin
ns17-Jul-02 6:37
ns17-Jul-02 6:37 
GeneralRe: modifymenu question -about adding item Pin
Roger Allen17-Jul-02 6:43
Roger Allen17-Jul-02 6:43 
GeneralRe: modifymenu question -about adding item Pin
ns17-Jul-02 8:26
ns17-Jul-02 8:26 
GeneralRe: modifymenu question -about adding item Pin
Roger Allen17-Jul-02 8:49
Roger Allen17-Jul-02 8:49 
GeneralRe: WoW! A new file to explore..... Pin
ns17-Jul-02 8:57
ns17-Jul-02 8:57 
GeneralRe: WoW! A new file to explore..... Pin
Shog917-Jul-02 11:13
sitebuilderShog917-Jul-02 11:13 
GeneralRe: WoW! A new file to explore..... Pin
Roger Allen18-Jul-02 0:11
Roger Allen18-Jul-02 0:11 
GeneralRe: WoW! A new file to explore..... Pin
ns18-Jul-02 1:22
ns18-Jul-02 1:22 

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.