I recently started programming for my NDS. Totally new to the whole NDS programming stuff I ran into the following problem on my first program already: I can't get writing a file to my micro SD to work... I am using a R4i card with my NDS Lite and a 4 GB SDHC micro SD.
Code: Select all
#include <nds.h>
#include <fat.h>
#include <stdio.h>
void pause()
{
// Wait for redraw of the display
swiWaitForVBlank();
// Tell the user what to do and wait
iprintf("Press START to continue\n");
do
{
scanKeys();
} while (!(keysDown() & KEY_START));
return;
}
int main(int argc, char **argv)
{
consoleDemoInit();
iprintf("Initialize libfat...\n");
if (!fatInitDefault())
{
iprintf("Could not initialize libfat!\n");
pause();
return 0;
}
iprintf("Begin write...\n");
pause();
FILE *fp = fopen("/text.txt", "w");
if(fp == NULL)
{
iprintf("Writing /text.txt: Error!\n");
pause();
return 0;
}
else
{
iprintf("Write something to /text.txt\n");
int test = fprintf(fp, "Test\n");
fclose(fp);
if (test <= 0)
{
iprintf("Didn't work... BUT WHY???\n");
}
else
{
iprintf("Number of chars: %d\n", test);
}
}
pause();
return 0;
}
I really can't explain it... Maybe you have an idea?
MfG naid00