It doesn't work. :(
The Compiler said:
"a value of type "char (*)[25]" cannot be assigned to an entity of type "int"" in file "/main.cpp", Line: 24, Col: 22
"a value of type "char (*)[25]" cannot be assigned to an entity of type "int"" in file "/main.cpp", Line: 25, Col: 22
"a value of type "char (*)[25]" cannot be assigned to an entity of type "int"" in file "/main.cpp", Line: 26, Col: 22
"a value of type "char (*)[25]" cannot be assigned to an entity of type "int"" in file "/main.cpp", Line: 27, Col: 22
"operand of "*" must be a pointer" in file "/main.cpp", Line: 35, Col: 36
"Unable to download. Fix the reported errors..." in file "/"
#include "mbed.h"
LocalFileSystem local("local");
Serial pc(USBTX,USBRX);
int main()
{
FILE *fp;
fp = fopen("/local/tabelle.txt", "w");
if(fp == NULL) {
pc.printf("Datei konnte nicht geoeffnet werden.\n");
} else {
char a[25] = "Zeit";
char b[25] = "Datum";
char c[25] = "Startdatum";
char d[25] = "Enddatum";
int tabelle[4][4];
tabelle[0][0] = &a;
tabelle[0][1] = &b;
tabelle[0][2] = &c;
tabelle[0][3] = &d;
int i, j;
// Loop, Y-Pos
for(i=0; i<5; i++) {
// Loop, X-Pos
for(j=0; j<5; j++) {
fprintf(fp, "%s ", *tabelle[i][j]);
}
fprintf(fp, "\n");
}
}
pc.printf("Done.\n");
fclose(fp);
}
It may need the table declaration to be char* rather than int, however that might work
Hello,
I want to write formatted text into a document. It works only with numbers, but when I write char's with text, then the compiler write the binary numbers instead of it.
Here's my code:
#include "mbed.h" LocalFileSystem local("local"); Serial pc(USBTX,USBRX); int main() { FILE *fp; fp = fopen("/local/tabelle.txt", "w"); if(fp == NULL) { pc.printf("Datei konnte nicht geoeffnet werden.\n"); } else { char a[25] = "Zeit"; char b[25] = "Datum"; char c[25] = "Startdatum"; char d[25] = "Enddatum"; int tabelle[4][4]; tabelle[0][0] = *a; tabelle[0][1] = *b; tabelle[0][2] = *c; tabelle[0][3] = *d; int i, j; // Loop, Y-Pos for(i=0; i<5; i++) { // Loop, X-Pos for(j=0; j<5; j++) { fprintf(fp, "%d ", tabelle[i][j]); } fprintf(fp, "\n"); } } pc.printf("Done.\n"); fclose(fp); }