memcpy in D
Tyro[17]
ridimz at yahoo.com
Sun Jun 30 04:07:23 PDT 2013
What is the equivalent of memcpy
module memcopy;
immutable ADDRESS_BUS_SIZE = 20; // 2^20 address bus
byte memory[1 << ADDRESS_BUS_SIZE];
void main()
{
ushort val = 12345;
for (int i = 0x12340; i < 0x1234A; i+= 2) {
memcpy (&memory[i], &val, sizeof val); // D way???
val++;
}
for (int i = 0x12340; i < 0x1234A; i+= 2) {
memcpy (&val, &memory[i], sizeof val); // D way???
writefln("%x", val);
}
}
achieved in D? I am trying not to use memcpy or any function from the C API.
Thanks,
--
Andrew Edwards
--------------------
http://www.akeron.co
auto getAddress() {
string location = "@", period = ".";
return ("info" ~ location ~ "afidem" ~ period ~ "org");
}
More information about the Digitalmars-d-learn
mailing list