1. Initialize fatlib and create a FILE variable.Hello,
can anyone tell me how i can writte something to a file using devkitpro (and c)?
Thanks
#include
fatInitDefault();
FILE* aFile;
char* buffer;
chdir("fat:/YourPath");
aFile = fopen ("aFileYouWantToCreate.Extension" , "wb" );
fwrite (buffer , 1 , sizeof(buffer) , aFile );
fclose (aFile);
It's a very simplified version - remember to malloc memory to the buffer.thank you
buffer = malloc(sizeof(YourContent));
You are correct - I made a boo boo. It was supposed to be fatInitDefault(); not the other way around, correct that and it'll work. Sorry, routine kills sometimes.Thank you, but i get this error:
...../main.c:41: undefined reference to `fatDefau
ltinit'
How can i fix it?
Change line:
LIBS:= -lnds9
Into:
LIBS:= -lfat -lnds9
Using libfat in a project
The following assumes that you are using one of the example NDS templates.
The first step is adding libfat to the list of libraries. In the ARM9 Makefile (or the top level one if there is no specific ARM9 Makefile), look for the list of libraries. It should look like:
LIBS := -lnds9
Change this to:
LIBS := -lfat -lnds9
The order is important! Make sure that -lfat comes before -lnds9. The include directory will already be set, so you don't need to worry about this.
hm, i still get the error