GP32 Saving A File


Sed

Still Fresh
Joined
Nov 22, 2004
Messages
9
Age
35
Location
NRW/Germany
Website
Visit site
Hi!

I want to save some things in a txt file,
but it don't works.

I have searched for answers in this forum, but I cant find them.

Please help me. :unsure:

That's my code:

Code:
#include <stdlib.h>
#include "gpdef.h"
#include "gpstdlib.h"
#include "gpgraphic.h"
#include "gpmain.h"
#include "gpstdio.h"
#include "gpfont.h"
#include "gpmem.h"
#include "gpmm.h"

const unsigned char thingstosave[5] = {
1, 2, 3, 4, 5
};

void GpMain(void *arg)
{
int i, j;
nflip = 1;
for(i = 0; i < 2; i++)
{GpLcdSurfaceGet(&gpDraw[i], i);}
GpSurfaceSet(&gpDraw[0]);

F_HANDLE *file;
GpFileCreate ("gp:\test.txt",ALWAYS_CREATE,&file);
GpFileWrite (file,&thingstosave,54);
GpFileClose (file);
}
 
You need to call GpFatInit() before you can write to the filesystem. Oh, and don't forget that \ is the escape character so you'll have to use gp:\\test.txt (\t is tab, \\ is ).
 
Last edited by a moderator:
Well said Woogal.

Sed: Also, Don't use 54 as the size, as you only have 5 bytes in your array, which could mean a memory access violation ( = data abort = reset with default firmware) when the GpFileWrite is called, giving you an empty file. If you just want to throw something in the file, use sizeof().
 
Back
Top