c4ev3 / EV3-Eclipse-Plugin

Create C/C++ EV3 projects and upload them, right out of Eclipse.
http://c4ev3.github.io
5 stars 6 forks source link

How can I create a text file on ev3? #12

Closed thodec95 closed 1 year ago

thodec95 commented 1 year ago

Hi there,

I tried to create and open a text file on the ev3, but it doesnt work. I used a similar code to create a text file on windows and it worked. After running the code below on the ev3 the display showed "file could not be opened". Does someone no wheres the problem and how to make the program run?

include

include

include

int main() {

InitEV3();
setAllSensorMode(COL_COLOR, NO_SEN,NO_SEN, US_DIST_MM);

FILE *Datei;
char brett[8];

brett[0] = '1';
brett[1] = '7';
brett[2] = '7';
brett[3] = '6';

Datei = fopen ("test.txt", "w");

if(Datei == NULL) {

    TermPrintln("file could not be opened\n");

}else {

    TermPrintln("file opened\n");
    fprintf(Datei, "%s\n", brett);

    // Datei schliessen
    fclose(Datei);
}
ButtonWaitForPress(BUTTON_ID_ENTER);
FreeEV3();
return 0;

}

a3f commented 1 year ago

You may not have write permission in your current working directory. Try writing to /media/card/test.txt instead.

thodec95 commented 1 year ago

It works. Thank you!

a3f commented 1 year ago

:)