i did not find some methods like al_fprintf().
and how to use fprintf?
how to use fprintf
I assume you already know how to use printf.
You simply add the stream as the first parameter to fprintf().
If you said
printf("Hello, world!\n");
it'd be the same as
fprintf(stdout,"Hello, world!\n");
but you can substitute some text file pointer for stdout, or stderr so redirection won't hide errors printed to console etc.
You simply add the stream as the first parameter to fprintf().
fprintf() expects a FILE, not an ALLEGRO_FILE. It might work anyway, but I wouldn't rely on it.
You can use snprintf() to create a formatted string, and then use al_puts() to write it to the file.
Hm, that might be a bit of an oversight. Might want to add a al_fprintf and similar to the api
Yes, that would be useful and nice to have, so I added it to the roadmap on the wiki. This is really not that hard to implement, so if anyone feels they want to do this, please do so and post your patch here or on the mailing list.
u = al_ustr_newf(fmt, "%s", "blah"); al_fputs(f, al_cstr(u)); al_ustr_free(u);