Mail Archives: djgpp/1998/04/13/14:16:34
TackMast writes:
>strcpy(buf, get_filename("c:\djgpp\bin\game.dat"));
This is garbage, for several reasons. In C, \ is the string escape
character, so you can't use it in string literals. Either use a double
\\, or / style slashes. btw. this line will cause some compiler warnings
about \d and \g being invalid escape sequences. Pay attention to these:
if the compiler warns you about something, it is probably a good idea to
fix it!
More generally, why are you doing this in such an overcomplicated way?
Calling get_filename() on a constant string is pointless: why not just
write "game.dat"? And why go to all the trouble of copying this into a
temporary array, when you could just pass it directly to
load_datafile()?
>data = load_datafile(buf);
Check for errors. This call might fail: if so you need to detect that,
print a warning, and abort the program.
>set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0);
Again, check for errors. If you just go around calling functions and
assuming that everything will always succeed, you have no way to tell
where the problem is when one of these calls fails to work correctly.
--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
"Pigs use it for a tambourine" - Frank Zappa
- Raw text -