I have unsigned short int (from 0 to 65535) and I must save it to the file, using stdio and consuming 2 bytes, but I don't know, how.
Any suggestions?
http://www.cplusplus.com/doc/tutorial/files/ It's good to read the whole thing, but the information you need is in 'Binary files' in the bottom half of the article.
ofstream outputFile;
outputFile.open("yourfile.dat");
unsigned short int i;
i = 10;
outputFile.write(&i, sizeof(i));
outputFile.close();