View Single Post
  #1 (permalink)  
Old November 27th, 2005, 03:52 PM
scoobie scoobie is offline
Authorized User
 
Join Date: Jan 2005
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default splitting large value 2^24

Hi,

i am trying to split a variable key1[2] into to 2. key1[0] should equal 256 which is 0x00000100 and key1[1] should equal 65356 which is 0x00010000 in hex. i keep getting a segmentation fault:

i have the following code:

#define SIZE 16777216

typedef struct
{
unsigned short poskey[2];
unsigned short text[2];
}str;

int main(int argc, char *argv[])
{
unsigned short key1[2], key2[2];
unsigned short p[2], c[2];

str res[SIZE];
str dec;
str *result;

for (i=0; i < SIZE; i++)
{
key1[0] = i & 0x00000100;
key1[1] = (i & 0x0010000);
encode(p, key1);
res[i].poskey[0] = key1[0];
res[i].poskey[1] = key1[1];
res[i].text[0] = p[0];
res[i].text[1] = p[1];
}

can any body help, i have know idea what to do

thanks in advanced

sc

Reply With Quote