If my sorting routine is correct. Why is it not rearranging the elements correctly?
Type: Posts; User: auxfire
If my sorting routine is correct. Why is it not rearranging the elements correctly?
Ah. I was thinking for tmp_address I would just need a size of a pointer and not the size of the element being copied. The values I enter still aren't being sorted right and I can't find a pattern to...
This code seems to switch the last two of the array..
for (int i = 1; i < (int)num; ++i) {
int j = i;
void *element = (char *)arg + j * size;
void *tmp_address = malloc...
Thank you for pointing that out! It's early morning here.. I completely forgot about the other item..
I'm passing an array into this function and it's taking the item at index 0 and replacing the rest of the array with it. Any idea where this is going wrong?
void generic_sort (void *arg, size_t...
I was doing some test. Buffer in memset is suppose to be numbers. And thanks grumpy I realized it's an array of 1000 doubles. I was used to creating char pointers and never really created an array...
I'm writing a program that reads from stdin and prints it back out. I'm getting a bunch of garbage then a seg fault.
double numbers[256];
memset (numbers, 0, sizeof (numbers));
for...
Thanks! I figured it out.
In my main function I have:
while (! isempty_queue (this_queue)) {
printf("%s\n", remove_from_queue(this_queue));
}
free_queue (this_queue);
Should I be freeing each individual return...
linepos is supposed to be lines. I was moving its scope and forgot to rename that one. I free each node in remove_from_queue, do I need to free each node's item then the node itself?
Here's the leak:
HEAP SUMMARY:
in use at exit: 302 bytes in 14 blocks
total heap usage: 30 allocs, 16 frees, 1,230 bytes allocated
302 bytes in 14 blocks are definitely lost in...