How would I do this? I want the value of the variable to be returned to its initial value of: char x[MAX_DIR_LENGTH]={0x0};
I've tried
Code:x[MAX_DIR_LENGTH]='\0'; x[MAX_DIR_LENGTH]={0x0};
How would I do this? I want the value of the variable to be returned to its initial value of: char x[MAX_DIR_LENGTH]={0x0};
I've tried
Code:x[MAX_DIR_LENGTH]='\0'; x[MAX_DIR_LENGTH]={0x0};
does the same as your initialisation.Code:memset( x, '\0', MAX_DIR_LENGTH );
Kurt
Or even just a regular for loop, which doesn't have the problem of figuring out the size of each element of the array.
memset( x, '\0', MAX_DIR_LENGTH * sizeof *x );
Will at least save embarrasment if your array isn't an array of chars
For example, using memset to clear arrays of pointers and floats is non-portable.
http://c-faq.com/malloc/calloc.html