hi all
i am using these two char arrays.Code:char buf[256] = {0}; char buf1[256] = {0};
how can free these buf and buf1 after using these(means to NULL)
can you please help me
thank you in advance
hi all
i am using these two char arrays.Code:char buf[256] = {0}; char buf1[256] = {0};
how can free these buf and buf1 after using these(means to NULL)
can you please help me
thank you in advance
Well you could do
memset( buff, 0, sizeof buff );
But if the next thing you're going to do is something like strcpy() or fgets() to the buffer, then you're just wasting time (and showing a lack of understanding as to what is going on).
There is however one case I can think of where memset would be appropriate before say strcpy(), but I don't think I've ever seen the appropriate question being asked. Presumably because people who are capable of discovering the problem are also capable of implementing the solution.
If your use of 'free' is in the memory allocation sense, then you simply return from the function in which they are declared, and then they're gone automatically.
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.