Author Topic: 'fopen' With Uncertain Parameters  (Read 7428 times)

Pueo

  • Rogueliker
  • ***
  • Posts: 263
  • Karma: +0/-0
    • View Profile
    • Email
'fopen' With Uncertain Parameters
« 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?
{O.o}
 |)__)
   ” ”   o RLY?

requerent

  • Rogueliker
  • ***
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: 'fopen' With Uncertain Parameters
« Reply #1 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.
« Last Edit: May 21, 2012, 09:22:52 PM by requerent »

guest509

  • Guest
Re: 'fopen' With Uncertain Parameters
« Reply #2 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.