I\'m very new to C, and I am having trouble with fwrite.
I\'m looking to use a struct that holds two values:
struct keyEncode{
unsigned short key[2];
Look at your variable definitions, and look at which one you are using in the sizeof call. Is it correct to be specifying the size of a pointer rather than the size of the data? Also check your usage of fwrite, I think you are specifying the "count" parameter incorrectly. It is defined as
size_t fwrite ( const void * ptr, size_t size, size_t count, FILE * stream );
The count parameter specifies the number of blocks of size size to write to the file.
I don't really want to give you the answer right away (someone else probably will), as this is tagged as homework - you should be learning :)