|
|
От: | gear nuke | |
| Дата: | 16.10.09 16:12 | ||
| Оценка: | -1 | ||
Это С, в С++ аналогично.7.20.3 Memory management functions
1. The pointer returned if the allocation
succeeds is suitably aligned so that it may be assigned to a pointer to any type of object
and then used to access such an object or an array of such objects in the space allocated
(until the space is explicitly deallocated).
_>void load(char const* buf)
_>{
_>unsigned short val1 = *reinterpret_cast<unsigned short const*>(buf);
_>buf += sizeof(unsigned short);
_>unsigned long val2 = *reinterpret_cast<unsigned long const*>(buf);
_>}
_>int main()
_>{
_>char* buf = new char[1000];
_>//.........
_>load(buf);
_>return 0;
_>}
_>