writing files using "string"

This is a discussion on writing files using "string" within the C++ Programming forums, part of the General Programming Boards category; I have included <string> and am trying to write out to a file but am getting some strange error messages. ...

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    4

    Question writing files using "string"

    I have included <string> and am trying to write out to a file but am getting some strange error messages.

    my code:

    f.write(current->text);

    what should I change, or use?

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    A string has a member function, c_str(), which returns a char *. Try that.

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    4
    Thanks.

    I'll give it a go shortly, I'm just presently adding code to add an animal to my animal game. (a uni assignment)

    Mike

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with writing to files
    By beanroaster in forum C++ Programming
    Replies: 10
    Last Post: 12-23-2007, 12:21 AM
  2. Reading & Writing files (Error)
    By Blackroot in forum C++ Programming
    Replies: 9
    Last Post: 01-10-2006, 11:55 AM
  3. Writing files to a CD
    By SyntaxBubble in forum Windows Programming
    Replies: 1
    Last Post: 04-16-2003, 05:43 PM
  4. *.COM Files? Writing them?
    By johnc in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 07-11-2002, 02:52 AM
  5. Making files, opening them, and writing to them
    By Unregistered in forum Game Programming
    Replies: 6
    Last Post: 06-18-2002, 10:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21