> 2)Then using a pointer byte to set all the elements of the table at the price 65280,form is 00 00 FF 00
You mean you have something like
Code:
int **arr;
// some calls to malloc to create dynamic two-dimensional table of integers (n, k).
char *ptr = arr; // huh?
This doesn't make a lot of sense.
Sure, you can do it, but you need to take into account a couple of things.
1. what the size of an integer is - in bytes; this is easy, it's just sizeof(int)
2. what the endianess of your machine is. This is a lot trickier to solve in any general way.
You see, if you just assume that int's are 4 bytes, then the endian issue means you need to either write "00 00 FF 00" or "00 FF 00 00"
If you're allowed to use one more temporary int, then life is a lot easier on the 2nd point. You can simply declare
int pattern = 65280;
Then filling the array one byte at a time consists purely of
memcpy(ptr,&pattern,sizeof(pattern));
in a loop which increments ptr in an appropriate manner.