LOL Salem.
> return 0;
> free (ptr);
Yeah, that'll work
Ofcourse it wont linuxdude. The process will never reach free(ptr); as your return statement is placed before it.
LOL Salem.
> return 0;
> free (ptr);
Yeah, that'll work
Ofcourse it wont linuxdude. The process will never reach free(ptr); as your return statement is placed before it.
hoping to be certified (programming in c)
here's the news - I'm officially certified.
Linuxdude's post is excusable, he just copied Tarik's and changed it around, he mustn't have compiled it, or thought about it.
Help populate a c/c++ help irc channel
server: irc://irc.efnet.net
channel: #c
I still notice that none of the attempts at calling malloc takes into account the length of the string which is intended to be copied.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
sorry abou the whole return free thing. chrismiceli is right. I just copied his code. I didn't even compile it. Well for the malloc I just guess i was lazyCode:malloc(strlen(mytext)+1));
> malloc(strlen(mytext)+1));
*Shakes head*
+1 point for remembering the +1
-1 point for not counting ()
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Thank you guys I am so appreciate with your help and I learn some important points too.
Thank you...