Example of reading and writing text file in microSD card for DISCO-F746. DISCO-F746 で microSD カードのテキスト・ファイルの読み書きを行う例.
Dependencies: BSP_DISCO_F746NG SDFileSystem_Warning_Fixed
Diff: main.cpp
- Revision:
- 1:7aa80a497ed2
- Parent:
- 0:3e46577dc273
- Child:
- 2:0705bf3a3e1e
--- a/main.cpp Sun Oct 09 10:11:14 2016 +0000 +++ b/main.cpp Wed Nov 02 03:21:08 2016 +0000 @@ -4,7 +4,7 @@ // mount(), unmount() を使うことを除けば通常のテキストファイルの // 読み書きと同じ. // -// 2016/10/09, Copyright (c) 2016 MIKAMI, Naoki +// 2016/11/02, Copyright (c) 2016 MIKAMI, Naoki //-------------------------------------------------------------- #include "mbed.h" @@ -19,7 +19,7 @@ sd.mount(); // SD 用 - // SD へ出力 + // SD へ書き込み FILE *fp = fopen("/sd/WriteReadTest.txt", "w"); if (fp == NULL) { @@ -31,13 +31,15 @@ fprintf(fp, "Example of writing and reading of text file.\n"); fclose(fp); - // SD から入力 - fp = fopen("/sd/TestWrite.txt", "r"); + // SD から読み出し + fp = fopen("/sd/WriteReadTest.txt", "r"); if (fp == NULL) { fprintf(stderr, "Open error for reading!!\r\n"); while (true) {} } + + printf("String in read file is as follows:\r\n"); while (true) {