sensor
Dependencies: BMP280 ELEC350-Practicals-FZ429 BME280
Diff: main.cpp
- Revision:
- 3:22e5460a8b42
- Parent:
- 2:fad34c30dcc4
- Child:
- 4:17fe5b63cd8a
--- a/main.cpp Wed Nov 22 15:18:28 2017 +0000 +++ b/main.cpp Thu Nov 23 10:54:42 2017 +0000 @@ -30,7 +30,7 @@ // Open to WRITE // ************* printf("Write to a file\n"); - FILE* fp = fopen("/sd/test.txt","w"); + FILE* fp = fopen("/sd/test.txt","a"); //Check file handle (stream) if (fp == NULL) { error("Could not open file for write\n"); @@ -53,11 +53,13 @@ errorCode(FATAL); } - //Read in three strings - char s1[64], s2[64], s3[64]; - fscanf(fp, "%s %s %s", s1,s2,s3); + //Read back all strings + char s1[64]; + while (fscanf(fp, "%s", s1) == 1) { + printf("READ BACK: %s\n", s1); + } //To read a whole line, use: fgets(s1, sizeof(s1), fp); - printf("READ BACK: %s %s %s\n", s1, s2, s3); + //Close File fclose(fp);