Witchie NL Posted November 1, 2006 Report Posted November 1, 2006 im to lazy to go to mgb forum's so ill post here1) How do you delete a file using ofstream();?2) Can you output Strings with ofstream();? 1: I need to delete a file.2: When i use a string in the output of ofstream() it gives strange codes.String p_bounty = "Witchie NL"; ofstream file("textfile.txt", ios::app); if (file) { file << "blabla:" << p_bounty << endl; }It writes this: blabla:00C41F50
Drake7707 Posted November 1, 2006 Report Posted November 1, 2006 i don't know much about c++ but i figure thats the address of the pointer that points to the string.
Witchie NL Posted November 2, 2006 Author Report Posted November 2, 2006 how can i revert it? ive seen it being stored in TM_Mer like that aswell (credits database) so ill check that plugin out aswell.
Bak Posted November 2, 2006 Report Posted November 2, 2006 You can't delete a file using ofstream. You need to use a system call. You can, however, clear a file's contents: // clear textfile.txt's contents ofstream fout("textfile.txt"); if (fout.fail()) { // error } else fout.close(); As for outputting a String to a file, Drake was correct: String p_bounty = "Witchie NL"; ofstream file("textfile.txt", ios::app); if (!file.fail()) { file << "blabla:" << p_bounty.msg << endl; file.close(); }
Drake7707 Posted November 2, 2006 Report Posted November 2, 2006 i was ? woo.. erhm yes of course i was
Witchie NL Posted November 2, 2006 Author Report Posted November 2, 2006 ok thx that was what i needed Edit: Added: And its working fine. I was adding some more stuff to my plugin and you dont wana know what happened. (if i tryed to start mervbot it came up with and error window and crashed the bot duno why it was coused but i removed all extra code and it worked fine again :S)
Recommended Posts