duguo.org »  last updated 17:48, 10 January 2008 by Du, Guo

C - Log text to a file

From duguo.org

Jump to: navigation, search

logToFile(char* msg){

	long file;
    file = fopen("c:\\debug.txt", "a+"); 
	if(file==NULL) {
		printf("Error: can't create file.\n");
		return 1;
	} else {
        fputs(msg, file);
        fputs("bb\n", file);
		fclose(file);
		return 0;
	}
}