Hi H-H,
I am sorry I cannot write the code for you, but I can point to to some MATLAB functions I know which could achieve what you are looking for:
1. You need not include header files in MATLAB.
2. Instead of main() function, you can define a function in MATLAB. For more info on MATLAB functions, refer this
3. You need not declare variables in MATLAB. MATLAB creates it on-the-go.
4. You need not use pointers for file operations. You can use fread , fscanf, fwrite and a host of other Low-Level File I/O functions described here
6. As a substitute for the 'C' function 'fprintf', you can use input. Similarly, as a substitute for the C function 'fprintf', you can use disp.
7. You cannot use the syntax '+=' in MATLAB. For a += b; you need to explicitly use
a = a+b
If you need anything more on this you can just comment on this thread, and I would be glad to help.
Hope this helps,
Cheers!
Abhiram.