declaring structs
Hi,
i'm new to c programming. i have declared a typedef struct that contains two arrays in it. the problem is when i try to reference something that is in the struct i get an error. here is the code
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
unsigned short key1[2];
unsigned short plain[2];
}code;
unsigned short *res_k1;
unsigned short *res;
main(int argc, char *argv[])
{
unsigned short k1[2],k2[2];
unsigned short p[2],c[2];
res_k1 = (unsigned short *) malloc(sizeof (code));
k1[0]=0x0000;
k1[1]=0x0000;
short i;
p[0]=0x0001;
p[1]=0x0002;
for (i=0; k1[0] < 0x00FF; i++)
{
for (i=0; k1[1] < 0xFFFF; i++)
{
encode(p, k1);
printf(" Result = ");
printf("(%4x,%4x) ",p[0],p[1]);
}
encode(p, k1);
printf(" Result = ");
printf("(%4x,%4x) ",p[0],p[1]);
}
} //end main
also i declare an array unsigned short[17000000]; does anybody know i pass in the results of p to that array;
thanks in advanced for all you help,
sc
|