When I try to change directories to load an image with the following code:
ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
const char * pathstr = al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP);
if (!al_change_directory(pathstr))
{
fprintf(stderr, "Erro na mudanca de diretorio.\n");
return -1;
}
the program simply crashes. It's really weird, since I got the code from older posts so it's supposed to be working.
Also, when I type printf("%s\n", al_get_current_directory); it just prints garbage.
printf("%s\n", al_get_current_directory);
Is this a copy-paste error?
Should be
printf("%s\n", al_get_current_directory());
edit: the above code causes a memory leak. So for proper practice...
char *directory = al_get_current_directory(); // use variable al_free(directory); // clean up
No, it was actually an error. Now it prints the directory where my source is. THank you! However, I've still got two problems: there is an image there that doesn't load AND my program crashes when I try to get my current directory.
do you call al_init before al_get_current_directory?
Yes, that was the case. Thank you.