I got an assignment where i have to read in unsigned short values from a .raw file. Im abit unsure on how i do this in C and what i get when i do it like i have tried to do
http://pastebin.com/NNQDitWe
Code:
void main()
{
//data is also an usnigned *short declared somewhere else in the program
data = ReadFile();
}
unsigned short* ReadFile()
{
FILE *file = fopen("Kaisa.raw", "r");
if(!file)
{
return NULL;
unsigned short* value = (unsigned short*)malloc(512*512*210*sizeof(unsigned short*));
fread(value, 512*512*210, 1, file);
fclose(file);
return value;
}
First of all, does this work?
If so what and how is the values stored in data. Is the numbers all in one line(that is 512*512*210 elements long)?