Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SDFileSystem mbed
Fork of Lab7-01_template by
main.cpp
00001 #include "mbed.h" 00002 #include "SDFileSystem.h" 00003 00004 Serial pc(USBTX,USBRX); 00005 SDFileSystem sd(p5, p6, p7, p8, "sd"); 00006 00007 int main() 00008 { 00009 pc.baud(9600); 00010 pc.printf("Hello world!\r\n"); 00011 char str[100]; 00012 mkdir("/sd/mydir", 0777); 00013 FILE *fp = fopen("/sd/mydir/test.txt","w"); 00014 if(fp == NULL) { 00015 error("Could not open file for write\r\n"); 00016 } 00017 for(int i=0; i<10; i++)fprintf(fp,"Hello my name is HEPTA!\r\n"); 00018 fclose(fp); 00019 fp = fopen("/sd/mydir/test.txt","r"); 00020 for(int j = 0; j < 10; j++) { 00021 fgets(str,100,fp); 00022 puts(str); 00023 } 00024 fclose(fp); 00025 pc.printf("Goodbye!!\r\n"); 00026 }
Generated on Fri Jul 15 2022 12:10:26 by
1.7.2
