Click here to Skip to main content
15,905,593 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionItem icon in Add/Remove progarms dialog Pin
LiYS7-Jan-07 20:43
LiYS7-Jan-07 20:43 
AnswerRe: Item icon in Add/Remove progarms dialog Pin
Monty27-Jan-07 20:59
Monty27-Jan-07 20:59 
Questionstrcpy working even after deleting the pointer Pin
pyarigopal7-Jan-07 20:42
pyarigopal7-Jan-07 20:42 
AnswerRe: strcpy working even after deleting the pointer Pin
Monty27-Jan-07 21:08
Monty27-Jan-07 21:08 
AnswerRe: strcpy working even after deleting the pointer [modified] Pin
Michael Dunn7-Jan-07 21:10
sitebuilderMichael Dunn7-Jan-07 21:10 
AnswerRe: strcpy working even after deleting the pointer Pin
Waldermort7-Jan-07 21:14
Waldermort7-Jan-07 21:14 
GeneralRe: strcpy working even after deleting the pointer Pin
pyarigopal8-Jan-07 18:21
pyarigopal8-Jan-07 18:21 
AnswerRe: strcpy working even after deleting the pointer Pin
CPallini7-Jan-07 21:25
mveCPallini7-Jan-07 21:25 
pyarigopal wrote:
still its printing good_morning with out throwing any exception.
why this is happening ?


Perhaps delete is only marking the memory chunk as free and strcpy doesn't matter about, as stated by MSDN:
The strcpy function copies strSource, including the terminating null character, to the location specified by strDestination. No overflow checking is performed when strings are copied or appended


try this:
char *p = new char[100];
delete [] p;
char *q = new char[100];
strcpy(p,"Hello world\n");
strcpy(q,"Good news...\n");
printf("%s", p);
printf("%s", q);


if you're a lucky boy, like me, you will see the following output:

Good news...
Good news...


hence you're loosing the freed memory.

As already stated by other posters, NEVER DO SUCH NASTY THINGS.
Smile | :)



If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

GeneralRe: strcpy working even after deleting the pointer Pin
prasad_som7-Jan-07 21:29
prasad_som7-Jan-07 21:29 
QuestionHow can i use Image magick in MFC? Pin
$uresh $hanmugam7-Jan-07 20:17
$uresh $hanmugam7-Jan-07 20:17 
AnswerRe: How can i use Image magick in MFC? Pin
Hamid_RT7-Jan-07 20:37
Hamid_RT7-Jan-07 20:37 
GeneralRe: How can i use Image magick in MFC? Pin
$uresh $hanmugam7-Jan-07 21:04
$uresh $hanmugam7-Jan-07 21:04 
GeneralRe: How can i use Image magick in MFC? Pin
Hamid_RT7-Jan-07 21:37
Hamid_RT7-Jan-07 21:37 
GeneralRe: How can i use Image magick in MFC? Pin
$uresh $hanmugam7-Jan-07 21:51
$uresh $hanmugam7-Jan-07 21:51 
QuestionDLL Injection vs Code Injection Pin
SelvaKr7-Jan-07 20:06
SelvaKr7-Jan-07 20:06 
AnswerRe: DLL Injection vs Code Injection Pin
Stephen Hewitt7-Jan-07 20:18
Stephen Hewitt7-Jan-07 20:18 
GeneralRe: DLL Injection vs Code Injection Pin
SelvaKr7-Jan-07 20:25
SelvaKr7-Jan-07 20:25 
QuestionTitle Pin
Try7-Jan-07 18:56
Try7-Jan-07 18:56 
AnswerRe: Title Pin
prasad_som7-Jan-07 19:17
prasad_som7-Jan-07 19:17 
GeneralRe: Title Pin
Try7-Jan-07 19:24
Try7-Jan-07 19:24 
QuestionDLL and Program Compile Pin
uusheikh7-Jan-07 18:54
uusheikh7-Jan-07 18:54 
AnswerRe: DLL and Program Compile Pin
Rajesh R Subramanian7-Jan-07 19:10
professionalRajesh R Subramanian7-Jan-07 19:10 
GeneralRe: DLL and Program Compile Pin
uusheikh7-Jan-07 19:22
uusheikh7-Jan-07 19:22 
AnswerRe: DLL and Program Compile Pin
Rajesh R Subramanian7-Jan-07 19:29
professionalRajesh R Subramanian7-Jan-07 19:29 
GeneralRe: DLL and Program Compile Pin
uusheikh7-Jan-07 19:51
uusheikh7-Jan-07 19:51 

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.