Page 1 of 1

[SOLVED] What's the best way to write strings to text files?

Posted: Sun Mar 07, 2010 8:32 pm
by Bullet Pulse
I would like to use something like fprintf(), but I can't send a string as the 2nd parameter, as it takes a const char*.
I don't have much experience with writing to text files, and I'm just trying to make a simple program that accepts a string,
manipulates that string, and then writes that string to a text file.

Thanks.

Re: What's the best way to write strings to text files?

Posted: Sun Mar 07, 2010 9:36 pm
by Bakkon
If you're working with a string and something requires a char*, you can use the c_str() method of your string object.

Re: What's the best way to write strings to text files?

Posted: Sun Mar 07, 2010 9:37 pm
by avansc

Re: What's the best way to write strings to text files?

Posted: Sun Mar 07, 2010 10:22 pm
by Bakkon
avansc wrote:edit: DAMN YOU!!!
:-*

Re: What's the best way to write strings to text files?

Posted: Sun Mar 07, 2010 10:32 pm
by short
hahaha bakkon won this time :P :mrgreen:

Re: What's the best way to write strings to text files?

Posted: Mon Mar 08, 2010 5:24 pm
by Bullet Pulse
Thanks everyone. I made a program to use this and it works. :)