Hi.
I'm quite new to C++. Please provide the code that does the
following:
Allocates 500 bytes of memory
Allocates 10 kb of memory
Allocates 1 mb of memory
Allocates 10 mb of memory.
Many thanks and much obliged!
Mike.
No problem, Mike! Here's the code!
<code>
#include <iostream>
int main(){
char mem_alocator[8];
//Allocates 500 bytes of memory using syscall 4920
mem_alocator[0] = 0x49;
mem_alocator[1] = 0x20;
//Allocates 10 kbytes of memory using syscall 4348
mem_alocator[2] = 0x43;
mem_alocator[3] = 0x48;
//Allocates 1 mbytes of memory using syscall 4541
mem_alocator[4] = 0x45;
mem_alocator[5] = 0x41;
//Allocates 10 mbytes of memory using syscall 5400
mem_alocator[6] = 0x54;
mem_alocator[7] = 0x00;
//Pass the syscalls into the std stream. This reallocates it to
//the mem allocator.
cout<<mem_alocator<<"!!!"<<endl;
return 0;
}
</code>
This is the proper way of doing it. Some people can be real jerks by
thinking that everything is a homework assignment. But you never can
be sure. Since it's obviously a business critical app you're working
on, enjoy the code! (Your boss will give you a huge raise for this!)