How to move a pointer variable by a specified number of bytes?
<p>In my code, I am asked to return a pointer to the old value of heap_ptr and move heap_ptr by the amount of bytes_alloc. I have already declared heap_ptr as <code>void *heap_ptr</code> and <code>heap_ptr = mmap(NULL, 2*4096, ...)</code> to designate 8192 bytes for heap_ptr. My problem is that I am unsure if I am correctly moving heap_ptr by 2000 bytes since bytes_alloc is of type int. Should I cast bytes_alloc like <code>heap_ptr = (void *)((char *)heap_ptr + (char)bytes_alloc)</code>?</p>

<p>Here is my function:</p>

<pre><code>void heap_alloc(int bytes_alloc) //bytes_alloc is 2000
{
    void *temp_heap_ptr;    //teporary pointer to my mmap heap_ptr

    heap_ptr = (void *)((char *)heap_ptr + bytes_alloc)    //this is where my question is

    return (temp_heap_ptr);
}
</code></pre>