Thread: C++ Code not adding text to text file

  1. #16
    Registered User
    Join Date
    Jun 2015
    Posts
    1,640
    I give up. I don't use Mac.

    However, Adrian was somewhat loose with his statement that it should appear where the executable is. It will actually appear in whatever the current directory is. You could run the executable from a different directory.

    Presumably you're running it from an IDE and it is assuming what you've shown as your current directory. You could try running it from a terminal instead.

  2. #17
    Registered User
    Join Date
    Aug 2017
    Posts
    8
    When I do, I get the following error: Invalid operends to binary expression ('if stream' (aka 'basic_ifstream<char>') and 'int')
    savefile << player.health

  3. #18
    Registered User
    Join Date
    Jun 2015
    Posts
    1,640
    Quote Originally Posted by Vanillla View Post
    When I do, I get the following error: Invalid operends to binary expression ('if stream' (aka 'basic_ifstream<char>') and 'int')
    savefile << player.health
    For some reason you've apparently changed ofstream to ifstream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 06-23-2017, 04:20 AM
  2. Making a string from a text file after a specific text
    By GypsyV3nom in forum C Programming
    Replies: 4
    Last Post: 06-22-2016, 01:11 PM
  3. adding text from file to a linked list
    By gioullis in forum C Programming
    Replies: 2
    Last Post: 06-05-2012, 11:29 AM
  4. Replace wildcard text in file with specific text.
    By untz in forum C++ Programming
    Replies: 4
    Last Post: 11-22-2010, 06:35 PM
  5. Replies: 4
    Last Post: 06-22-2002, 12:23 PM

Tags for this Thread