Simple Problem

This is a discussion on Simple Problem within the C Programming forums, part of the General Programming Boards category; I am creating a text-based rpg. I need a way to create save files for the stats of a character ...

  1. #1
    Registered User Black_Epiphany's Avatar
    Join Date
    Sep 2011
    Posts
    15

    Cool Simple Problem

    I am creating a text-based rpg. I need a way to create save files for the stats of a character ( a bunch of integer variables ) to any directory on the pc and be able to load them at will the next time the program starts.

    Any tutorials or tips you can help me with?

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    2,372
    Start with basic file i/o

    Cprogramming.com FAQ > Work with files (C)

    Tim S.

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Instead of specifying a particular directory, have the game data file use the same directory as the game program file, uses. No specification should be needed for that, completely avoiding the whole "what directory" problem.

  4. #4
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,866
    Also, to expand on stahta01's post, you specifically want to be looking at doing binary files for this and here is our Tutorial on File Operations
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  5. #5
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Adak View Post
    Instead of specifying a particular directory, have the game data file use the same directory as the game program file, uses. No specification should be needed for that, completely avoiding the whole "what directory" problem.
    That may not be as simple as it seems, especially on Vista and Win7...

    User Account Control Data Redirection

    Depending upon a user's priveledge level their file i/o and registry i/o might take something of a left turn on them...

  6. #6
    Registered User Black_Epiphany's Avatar
    Join Date
    Sep 2011
    Posts
    15
    I am on Linux (ubuntu) btw. Thanks for the help guys.

  7. #7
    Registered User TheBigH's Avatar
    Join Date
    May 2010
    Location
    Melbourne, Australia
    Posts
    426
    Quote Originally Posted by Black_Epiphany View Post
    I am on Linux
    Good.
    Code:
    while(!asleep) {
       sheep++;
    }

  8. #8
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Black_Epiphany View Post
    I am on Linux (ubuntu).
    Please allow me to express my most sincere condolences...

    (Just kidding)

  9. #9
    Registered User Black_Epiphany's Avatar
    Join Date
    Sep 2011
    Posts
    15
    I really like this forum. Much better and friendlier than others I have tried in the past.

  10. #10
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I'm on Win7 and have had no problem with file access for any of my programs, but I am also logged in with high authorization. I also run a Ubuntu rig, and it handles file access similarly, but again, I'm logged in with high authorization.

    @Black_Epiphany, we're just going easy on ya!

  11. #11
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Adak View Post
    I'm on Win7 and have had no problem with file access for any of my programs, but I am also logged in with high authorization. I also run a Ubuntu rig, and it handles file access similarly, but again, I'm logged in with high authorization.

    @Black_Epiphany, we're just going easy on ya!
    Actually the whole redirection thing is defeatable anyway... Just add a manifest to the executable's resources...
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
      <assemblyIdentity type="win32"
                        name="AutoLogon"
                        version="1.0.0.0"
                        processorArchitecture="X86" />
      <description>
        Auto logon tool
      </description>
      <dependency>
        <dependentAssembly>
          <assemblyIdentity type="win32"
                            name="Microsoft.Windows.Common-Controls"
                            version="6.0.0.0"
                            processorArchitecture="X86"
                            publicKeyToken="6595b64144ccf1df"
                            language="*" />
        </dependentAssembly>
      </dependency>
      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
        <security>
          <requestedPrivileges>
            <requestedExecutionLevel  level="asInvoker" 
                                      uiAccess="false" /> 
          </requestedPrivileges>
        </security>
      </trustInfo>
    </assembly>
    Changes will be needed on a program by program basis for the assembly name (program name without extension), assembly description and platform (x86 or amd64 in most cases).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple program, simple problem
    By KAUFMANN in forum C Programming
    Replies: 5
    Last Post: 02-16-2011, 12:16 PM
  2. Simple program...simple problem?
    By deadherorising in forum C Programming
    Replies: 2
    Last Post: 03-12-2009, 08:37 PM
  3. Simple program, not so simple problem
    By nolsen in forum C++ Programming
    Replies: 2
    Last Post: 01-18-2008, 09:28 AM
  4. C++ simple problem
    By spinaltap in forum C++ Programming
    Replies: 13
    Last Post: 06-11-2007, 02:59 PM
  5. A Simple (?) Problem
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 10-12-2001, 04:28 AM

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