StrPtr::Atoi()

Return the numeric value, if any, represented by this StrPtr's buffer.

Virtual?

No

 

Class

StrPtr

 

Arguments

None

 

Returns

int

integer value of the string

Notes

StrPtr::Atoi() is equivalent to calling atoi(StrPtr::Text()). Non-numeric strings typically return a value of zero.

Example

#include <stdhdrs.h>
#include <strbuf.h>

int main( int argc, char **argv )
{
    StrBuf str1;
    StrBuf str2;

    str1.Set( "123" );
    str2.Set( "234" );

    printf( "%s + %s = %d\n",
        str1.Text(), str2.Text(), str1.Atoi() + str2.Atoi() );
}

Executing the preceding code produces the following output:

123 + 234 = 357