Hello I am running a spi file I/O test. but I do not why I cannot process my fopen function. building target is good. please tell me if you hachar fileread(void) {
FILE *fp;//file pointer char readsample; fp=fopen("C://work/firmware/0718_spi_fileio/Hello.txt","r"); //transfer file char to array if(fp==NULL)//error;cannot find file { return(0); } else{ while ((readsample=fgetc(fp))!=EOF) { putchar(readsample); } fclose(fp); return(readsample); } } ve any suggestion.
char fileread(void) {
FILE *fp;//file pointer char readsample; fp=fopen("C://work/firmware/0718_spi_fileio/Hello.txt","r"); //transfer file char to array if(fp==NULL)//error;cannot find file { return(0); } else{ while ((readsample=fgetc(fp))!=EOF) { putchar(readsample); } fclose(fp); return(readsample); } }
code shown above.
Please read the posting tips about in-lining source code.
You're hosting the File IO how exactly?
fopen() returns a NULL? Or crashes?
Use of slashes is also inconsistent.
"C://work/firmware/0718_spi_fileio/Hello.txt"
fopen crashed I think. it cannot process next step once I enter Debug session.