I thouht it would be nice to have a c/c++ snippet thread here in the PSP Development Forum as a lot of poeple cannot post in the Developer's Dungeon (ie. myself). I'm a bit busy at the moment so I will post a few examples a bit later.
- No flaming (Yes, I did ask a mod if this was okay)
- You may post snippets/examples or mini-tutorials
- In order to keep this organized, if you aren't going to post a snippet/tutorial, please to do not post. If you have a concern about a snippet, feel free to say what you need to say. Otherwise, please refrain from posting. You do not need to congratulate someone in this thread. Please use PM's. (Any useless posts will be deleted)
- Have fun!
Please use the following format.
Originally Posted by Formatting Posts
You may use a similar format for tutorials as long as you use code tags.
-= Double Post =-
Snippet Name: HTML Logger
Snippet Purpose: Logs a message into a table of an HTML file. (I use it for error logging)
Fixed the function. Thanks IWN and yaustar.Code:
char* html_logger(char* inBuf) // inBuf = message to log
FILE* fp = fopen("log.html", "a"); //File to open. "a" for append, or write to end of file
char* buf = (char*) malloc(sizeof(char)); //get space for the buffer
sprintf(buf, "\n<table>\n<tr>\n<td>\n<b><font color=\"rgb(150, 150, 150)\">Log:</font></b>\n</td>\n</tr>\n<tr>\n<td>\n<font color=\"rgb(100, 100, 100)\" size=\"2\">%s</font>\n</td>\n</tr></table>\n\n", inBuf); //format 'inBuf' into our html
fprintf(fp, buf); //Write to the html file