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.
[SOLVED] What's the best way to write strings to text files?
Moderator: Coders of Rage
- Bullet Pulse
- Chaos Rift Cool Newbie
- Posts: 89
- Joined: Sun Feb 21, 2010 6:25 pm
[SOLVED] What's the best way to write strings to text files?
Last edited by Bullet Pulse on Mon Mar 08, 2010 5:24 pm, edited 1 time in total.
- Bakkon
- Chaos Rift Junior
- Posts: 384
- Joined: Wed May 20, 2009 2:38 pm
- Programming Language of Choice: C++
- Location: Indiana
Re: What's the best way to write strings to text files?
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?
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
Dad, "Yea well I have a fan belt in street fighting"
- Bakkon
- Chaos Rift Junior
- Posts: 384
- Joined: Wed May 20, 2009 2:38 pm
- Programming Language of Choice: C++
- Location: Indiana
Re: What's the best way to write strings to text files?
:-*avansc wrote:edit: DAMN YOU!!!
- short
- ES Beta Backer
- Posts: 548
- Joined: Thu Apr 30, 2009 2:22 am
- Current Project: c++, c
- Favorite Gaming Platforms: SNES, PS2, SNES, SNES, PC NES
- Programming Language of Choice: c, c++
- Location: Oregon, US
Re: What's the best way to write strings to text files?
hahaha bakkon won this time :P
My github repository contains the project I am currently working on,
link: https://github.com/bjadamson
link: https://github.com/bjadamson
- Bullet Pulse
- Chaos Rift Cool Newbie
- Posts: 89
- Joined: Sun Feb 21, 2010 6:25 pm
Re: What's the best way to write strings to text files?
Thanks everyone. I made a program to use this and it works.