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

C / C++ / MFC

 
GeneralRe: wcscpy_s issues [modified] Viorel Bejan Pin
big_denny_2002-Jun-06 6:07
big_denny_2002-Jun-06 6:07 
GeneralRe: wcscpy_s issues [modified] Viorel Bejan Pin
George L. Jackson2-Jun-06 8:17
George L. Jackson2-Jun-06 8:17 
GeneralRe: wcscpy_s issues [modified] Viorel Bejan Pin
big_denny_2002-Jun-06 8:25
big_denny_2002-Jun-06 8:25 
GeneralRe: wcscpy_s issues [modified] Viorel Bejan Pin
George L. Jackson2-Jun-06 11:14
George L. Jackson2-Jun-06 11:14 
GeneralRe: wcscpy_s issues [modified] Pin
Nish Nishant2-Jun-06 6:11
sitebuilderNish Nishant2-Jun-06 6:11 
AnswerRe: wcscpy_s issues [modified] Pin
Nemanja Trifunovic2-Jun-06 5:41
Nemanja Trifunovic2-Jun-06 5:41 
GeneralRe: wcscpy_s issues [modified] Pin
Nish Nishant2-Jun-06 6:10
sitebuilderNish Nishant2-Jun-06 6:10 
AnswerRe: wcscpy_s issues [modified] Pin
georgeraafat2-Jun-06 15:06
georgeraafat2-Jun-06 15:06 
According to:
http://msdn2.microsoft.com/en-us/library/td1esda9.aspx[^]

the sizeof(array) should correspond to the number of 'characters' - not 'bytes'.
So - in case of ANSI, it's bytes. In case of unicode, it's words (2-bytes).

When the code you listed compiles for unicode, sizeof(array) is 200 - which is double the actual number of characters.

Note that _tcscpy_s() zeros out the buffer after copying... and that's when you get the buffer overrun. You can find that out by stepping into _tcscppy().

You can use (sizeof(array)/sizeof(array[0])) or the _countof() macro.

gmileka
QuestionWndows application with buttons and controls Pin
LCI2-Jun-06 4:47
LCI2-Jun-06 4:47 
QuestionRe: Wndows application with buttons and controls Pin
David Crow2-Jun-06 5:12
David Crow2-Jun-06 5:12 
AnswerRe: Wndows application with buttons and controls Pin
LCI2-Jun-06 5:25
LCI2-Jun-06 5:25 
GeneralRe: Wndows application with buttons and controls Pin
David Crow2-Jun-06 5:31
David Crow2-Jun-06 5:31 
QuestionDialog events not showing Pin
ldaoust2-Jun-06 3:48
ldaoust2-Jun-06 3:48 
AnswerRe: Dialog events not showing Pin
Viorel.2-Jun-06 4:39
Viorel.2-Jun-06 4:39 
GeneralRe: Dialog events not showing Pin
ldaoust2-Jun-06 6:27
ldaoust2-Jun-06 6:27 
AnswerRe: Dialog events not showing (problem solved) [modified] Pin
ldaoust11-Jul-06 3:52
ldaoust11-Jul-06 3:52 
QuestionStatic registry for classfactory handles Pin
rana742-Jun-06 2:20
rana742-Jun-06 2:20 
QuestionForeground process Pin
KKumarTG2-Jun-06 2:20
KKumarTG2-Jun-06 2:20 
AnswerRe: Foreground process Pin
Ștefan-Mihai MOGA2-Jun-06 2:26
professionalȘtefan-Mihai MOGA2-Jun-06 2:26 
QuestionRe: Foreground process Pin
David Crow2-Jun-06 3:18
David Crow2-Jun-06 3:18 
AnswerRe: Foreground process Pin
Sebastian Schneider2-Jun-06 3:23
Sebastian Schneider2-Jun-06 3:23 
GeneralRe: Foreground process Pin
David Crow2-Jun-06 3:31
David Crow2-Jun-06 3:31 
GeneralRe: Foreground process Pin
KKumarTG2-Jun-06 3:49
KKumarTG2-Jun-06 3:49 
GeneralRe: Foreground process Pin
David Crow2-Jun-06 4:21
David Crow2-Jun-06 4:21 
GeneralRe: Foreground process Pin
KKumarTG2-Jun-06 5:23
KKumarTG2-Jun-06 5:23 

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.