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.
Fork of MicroBitDALImageRewrite by
main_string_test.cpp
00001 #include "inc/MicroBitTest.h" 00002 00003 #ifdef MAIN_STRING_TEST 00004 00005 #include "MicroBit.h" 00006 #include "ManagedString.h" 00007 00008 MicroBit uBit; 00009 Serial pc(USBTX, USBRX); 00010 00011 00012 void f1(ManagedString s) 00013 { 00014 pc.printf("f1: %s\n", s.toCharArray()); 00015 } 00016 00017 void f2(ManagedString s) 00018 { 00019 ManagedString s2=s; 00020 pc.printf("String: %s\n", s2.toCharArray()); 00021 } 00022 00023 void f3(ManagedString s1, ManagedString s2) 00024 { 00025 ManagedString t = s1+s2; 00026 00027 pc.printf("String: %s\n", t.toCharArray()); 00028 } 00029 00030 int main() 00031 { 00032 // Set up debug console. 00033 pc.baud (115200); 00034 00035 wait(10.0); 00036 00037 pc.printf("=== Starting String Test ===\n"); 00038 00039 ManagedString a("Alice"); 00040 ManagedString b("Bob"); 00041 ManagedString c("Charlie"); 00042 ManagedString d = a.substring(0,3); 00043 00044 f1(a); 00045 f2(b); 00046 f3(c,b); 00047 00048 pc.printf("String: %s\n", d.toCharArray()); 00049 00050 while(1) 00051 { 00052 wait(1.0); 00053 } 00054 } 00055 00056 #endif
Generated on Thu Jul 14 2022 13:31:29 by
