fwrite
how to get hexdump of a structure data
The following code will give you a hex dump of arbitrary memory from within your code. #include <stdio.h> // Usage: // hexDump(desc, addr, len, perLine); // desc: if non-NULL, printed as a description before hex dump. // addr: the address to start dumping from. // len: the number of bytes to dump. // perLine: number … Read more
What’s more efficient – storing logs in sql database or files?
Logs using files are more efficient, however logs stored in the database are easier to read, even remotely (you can write a web frontend if required, for example). Note however that connecting and inserting rows into the database is error prone (database server down, password wrong, out-of-resources) so where would you log those errors if … Read more
Writing a new line to file in PHP (line feed)
Replace ‘\n’ with “\n”. The escape sequence is not recognized when you use ‘. See the manual. For the question of how to write line endings, see the note here. Basically, different operating systems have different conventions for line endings. Windows uses “\r\n”, unix based operating systems use “\n”. You should stick to one convention … Read more