Cpstring Comparison; Useful String Functions - Casio ClassPad 300 Programming Manual

Sdk programming guide
Hide thumbs Also See for ClassPad 300:
Table of Contents

Advertisement

OBCD x;
Cal_setpi_OBC(&x);
CPString pi(x, 10); // pi="3.14159265"

CPString Comparison

The comparison operators == and != are defined as:
int operator==(const CPString& y);
int operator!=(const CPString& y);
The Standard C function strcmp is also available by using these functions:
int
Compare(const CPString& y) const;
int
Compare(PEGCHAR * lpsz) const;
Here is an example that uses these functions:
int i;
if(str2 == str3)
{
if(str1 != str2)
{
i = str2.Compare("this will fail");
}
}

Useful String Functions

The CPString class comes with a variety of string functions that will allow you to
manipulate a string in many different ways.
First of all, if you need to know the value of a character at a certain index, the []
operator is defined so that the following code is valid:
CPString str;
str = "test";
CP_CHAR c = str[1]; // c is 'e'
You can also retrieve the raw text buffer with any of the following three functions:
const PEGCHAR* Text();
operator LPPEGCHAR();
PEGCHAR *GetBuffer();
Be aware that the pointer returned by these functions is temporary and should never be
saved or modified. This buffer can become invalid when other CPString members are
called (like += etc) or when the object goes out of scope
Another common request is for the length of a string. The follow functions help get a
string's length:
100

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents