Changes between Initial Version and Version 1 of Docs/Prog/Manual/ApplicationLibraries/lib825ev/String


Ignore:
Timestamp:
08/20/10 08:22:44 (14 years ago)
Author:
Don Wilson
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Docs/Prog/Manual/ApplicationLibraries/lib825ev/String

    v1 v1  
     1= String Functions =
     2The 825 can be programmed using C/C++ character array strings and the standard C library such as:
     3{{{
     4char szMsg[10];
     5char szID[10];
     6strcpy(szID, "123");
     7sprintf(szMsg, "ID: %s", szID);
     8PrintLCD(szMsg);
     9}}}
     10
     11The is the traditional C programming way of handling strings. The C language has no true string type; strings are just arrays of characters. This is very fast and efficient because the compiler just generates code to read and write the memory directly as it is coded. However, there is no automatic checking that pointers point to valid memory, or to prevent writing beyond memory that is allocated. It is very easy to crash an 825 indicator by programming this the code incorrectly.
     12
     13The 825 also supports a newer C++ string type std::string. Using std::string does not require as much diligence from the programmer. The string will automatically allocate more memory and grow if needed by an assignment. The operations are also more like the BASIC language so this is helpful for programmers who are not as skilled in C/C++.
     14
     15{{{
     16string strMsg;
     17strMsg = "ID: ";
     18string strID = "123";
     19strMsg = strMsg + strID;
     20PrintLCD(strMsg);
     21}}}