Lectura/escritura de cadena de caracteres en fichero.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
jangelgm
Date:
Thu Mar 09 21:50:37 2017 +0000
Commit message:
Lectura/escritura de cadena de caracteres en fichero.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Mar 09 21:50:37 2017 +0000
@@ -0,0 +1,17 @@
+/* Program Example 10.2: Read and write text string data
+*/
+#include "mbed.h"
+Serial pc(USBTX,USBRX); // setup terminal link
+LocalFileSystem local("local"); // define local file system
+char write_string[64]; // character array up to 64 characters
+char read_string[64]; // create character arrays (strings)
+int main ()
+{
+    FILE* File1 = fopen("/local/textfile.txt","w"); // open file access
+    fputs("lots and lots of words and letters", File1); // put text into file
+    fclose(File1); // close file
+    FILE* File2 = fopen ("/local/textfile.txt","r"); // open file for reading
+    fgets(read_string,256,File2); // read first data value
+    fclose(File2); // close file
+    pc.printf("text data: %s \n",read_string); // display read data string
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Mar 09 21:50:37 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34
\ No newline at end of file