In C, How can I reset a given pointer to have all values in an array be a specified value? Is it best using a for loop, or is there a function that I can use to set all values in an array to 0.
My code currently is something like this:
int main()
{
double *my_values = calloc(10, sizeof(double));
do_something_with_values(my_values);
free(my_values);
my_values = calloc(10, sizeof(double));
do_something_else_with_values(my_values);
free(my_values);
}
This (to me) seems hacky, how can I improve this code?