Hello
I want to write/read data to a file on an SDHC card and I adapted a program SDHCFileSystem. I cant seem to open or create a file.Can anyone shed any light on this please ?
<<code>>
- include "mbed.h"
- include "string"
- include "SDHCFileSystem.h"
- define MAXLINE 100
Serial pc(USBTX, USBRX); tx, rx
char myline [MAXLINE];
SDFileSystem sd(p5, p6, p7, p8, "sd"); mosi, miso, sclk, cs
int main() {
pc.printf("\n\rIn the main program");
FILE *fp;
fp = fopen("/myfile.txt", "w+");
if(fp==NULL)
{
pc.printf("File not created or opened");
}
else
{
fprintf(fp, "\n\rHello World!\n\r");
fscanf(fp,"%s",&myline); just reads the first word 'Hello'
pc.printf("\n\rRead from SD card file: \"%s\"",myline);
fclose(fp);
}
}
<</code>>
Hello I want to write/read data to a file on an SDHC card and I adapted a program SDHCFileSystem. I cant seem to open or create a file.Can anyone shed any light on this please ?
<<code>>
int main() { pc.printf("\n\rIn the main program"); FILE *fp; fp = fopen("/myfile.txt", "w+"); if(fp==NULL) { pc.printf("File not created or opened"); } else { fprintf(fp, "\n\rHello World!\n\r"); fscanf(fp,"%s",&myline); just reads the first word 'Hello' pc.printf("\n\rRead from SD card file: \"%s\"",myline); fclose(fp); }
}
<</code>>