File I/O problem.

This is a discussion on File I/O problem. within the C++ Programming forums, part of the General Programming Boards category; This- Code: ofstream savefile("arenasave.sav"); -is giving me this error: Code: varieable `std:: ofstream savefile' has initializer but I have no ...

  1. #1
    Registered User Ranedhel's Avatar
    Join Date
    Jun 2003
    Posts
    34

    Question File I/O problem.

    This-

    Code:
    ofstream savefile("arenasave.sav");
    -is giving me this error:

    Code:
    varieable `std:: ofstream savefile' has initializer but
    I have no idea what that means.

    (Note: Before I upgraded to the latest Dev C++ it worked fine)
    Last edited by Ranedhel; 07-25-2003 at 07:27 PM.
    -Elven Forge Software-
    (Lead Designer)

    http://www.geocities.com/elvenforge

    **infected by frenchfry164**
    I am a signature virus. Please add me to your signature so that I may multiply

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    This works fine here:
    Code:
    #include <fstream>
    using namespace std;
    int main()
    {
      ofstream savefile("arenasave.sav");
    }
    I suggest you post a bit more of your code if it still doesn't work.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User Ranedhel's Avatar
    Join Date
    Jun 2003
    Posts
    34

    Re:

    Well, I tested the code on a different computer with the same compiler, and it worked fine.

    ...but...

    I did have some errors installing the compiler so I am reinstalling it. Maybe the problem lies with it, not my code.

    BTW: Do I need to include the "Using Namespace Std"?
    -Elven Forge Software-
    (Lead Designer)

    http://www.geocities.com/elvenforge

    **infected by frenchfry164**
    I am a signature virus. Please add me to your signature so that I may multiply

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    namespaces

    >> Do I need to include the "Using Namespace Std"?
    Its best to tell the compiler which namespace your functions are in. You can do it various ways, as the FAQ shows.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  5. #5
    Registered User Ranedhel's Avatar
    Join Date
    Jun 2003
    Posts
    34

    Re:

    Ah.

    Anyway, it was my compiler, reinstalling fixed it.
    -Elven Forge Software-
    (Lead Designer)

    http://www.geocities.com/elvenforge

    **infected by frenchfry164**
    I am a signature virus. Please add me to your signature so that I may multiply

  6. #6
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    I've had that problem with the latest Dev compiler as well... usually I just recompile it a few times and it will work... other times I have to restart my computer and try again.
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File i/o problem
    By tezcatlipooca in forum C++ Programming
    Replies: 18
    Last Post: 01-01-2007, 09:01 AM
  2. File I/O problem
    By Onions in forum C++ Programming
    Replies: 41
    Last Post: 02-24-2006, 04:32 PM
  3. File I/O problem
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 12
    Last Post: 09-03-2005, 01:14 PM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM

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