Temple of The Roguelike Forums

Development => Programming => Topic started by: Pueo on May 21, 2012, 09:09:30 PM

Title: 'fopen' With Uncertain Parameters
Post by: Pueo on May 21, 2012, 09:09:30 PM
Hola,
Say I'm using a file to hold the title screen, and when the program opens it up, it copies the file to the screen, with attributes and stuff that are to be added after. 
If I'm using fopen to provide a title screen file, how do I include the correct path when it's unknown what the path will be on a different user's computer?
Title: Re: 'fopen' With Uncertain Parameters
Post by: requerent on May 21, 2012, 09:19:00 PM
fopen should check from the current directory.


c:\programs\blah\myGame\myGame.exe
C:\programs\blah\myGame\assets\titlescreen.jpg


fopen("assets\\titlescreen.jpg");

What you're asking about is the relative path. Google "fopen relative path" for more information.


You don't need to include the entire path from the root directory, just the path from the executable directory. It can depend on how you have things set up and what you're targeting.
Title: Re: 'fopen' With Uncertain Parameters
Post by: guest509 on May 22, 2012, 08:01:18 AM
  Exactly. This is standard in any game that calls to included files. They are installed in the same folder as the game .exe or are in a folder nested within the game directory.