Function to Use String
Dependencies: mbed
main.cpp
- Committer:
- sweilz
- Date:
- 2015-11-13
- Revision:
- 1:906bda113ceb
- Parent:
- 0:624614538ca8
File content as of revision 1:906bda113ceb:
#include "mbed.h" #include <string> Serial pc(SERIAL_TX, SERIAL_RX); int main() { string txt("Hello World My Name is Liews"); string str; //txt.clear(); //Clear String //int x = txt.empty(); // return 1 if String is Empty //pc.printf("size: %d\n",txt.size()); // return size of string //pc.printf("length: %d\n",txt.length()); //return size od string //pc.printf("operator[]: %c\n",txt[10]); //access to charecter in string //pc.printf("at: %c\n",txt.at(10)); //access to charecter in string //txt += " Tong"; // add string to string //txt.append("s"); // add string to string //txt.push_back('K');// add charecter to string //str.assign(txt,15,4); //split string at index first and length //str.assign("Chawanluck Martchan",10); // cut string by length //str.assign("Hello"); // assign string //str.assign(10,'*'); // make string ********** pc.printf("string txt: %s\n",txt.c_str()); pc.printf("string txt: %s\n",txt.c_str()); }