Hi, my question is:
if I use strdup(), do I have to use free() at the end of the program (like when using malloc/realloc)?
Hi, my question is:
if I use strdup(), do I have to use free() at the end of the program (like when using malloc/realloc)?
1. strdup is not a standard function, so beware if you're writing portable programs.
2. Yes, you need to free, just like you would do with malloc
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.
thanks salem