strings, strings, strings ...

strings, strings, strings ...

Post by the dEAthMaKE » Mon, 02 Sep 2002 11:49:07



Heya,

  I began coding C++ with Borland C++ Builder and actually never really
bothered for things like strcmp and stuff
  i have 2 questions ..

  first .. the function itoa or StrItoA, does it require an existing buffer
as char* or will it create one and change the value accordingly ?
  (which makes more sense in my eyes since i cant know how long the output
string will be, can be 5 or can be 324.34423)

  second question ....

  is there some kind of string class in cw8 ? i cant overcome the "loss" of
my AnsiString class from bcb =(
  all the char* stuff takes too much time .. id rather like to spend it on
the important things .. if i need to reallocate memory manually
  everytime i wanna put 2 strings together of create some kind of output ill
start dreaming about chars pretty soon ... and i really really
  dont want THAT to happen ;)

regards,
  J?rg Eitemller

--

            . )) -:|:-
              ?.  .))
            ((??.  .   -:|:-
            -:|:-  ((??.* dth

 
 
 

strings, strings, strings ...

Post by Ben Combe » Mon, 02 Sep 2002 15:21:19



Quote:> Heya,

>   I began coding C++ with Borland C++ Builder and actually never really
> bothered for things like strcmp and stuff
>   i have 2 questions ..

>   first .. the function itoa or StrItoA, does it require an existing buffer
> as char* or will it create one and change the value accordingly ?
>   (which makes more sense in my eyes since i cant know how long the output
> string will be, can be 5 or can be 324.34423)

No, it requires you to supply a buffer.  If you read the StringMgr.h
header, you'll find the lines:

// Max length of string returned by StrIToA, for -2147483647, plus space
// for the terminating null.
#define maxStrIToALen   12

This is what you should use as a minimum for allocation your buffer for
the output from StrIToA.

Consider this: if StrIToA allocated its own buffer, then why would it
require you to pass it a pointer.  Then, how would it return this new
pointer to you, since the parameters are passed by value?

Quote:>   is there some kind of string class in cw8 ? i cant overcome the "loss" of
> my AnsiString class from bcb =(

Yes.  CodeWarrior for Palm OS V8 supports the standard C++ header
<string> and the template class basic_string, of which string is a
typedef for basic_string<char, ...>

As an alternative, buy a copy of the Object Library for Palm OS, which
provides a great C++ class library built around Palm OS, including a
nice CString class.  See http://www.aqpoint.com/pol/.

Quote:>   all the char* stuff takes too much time .. id rather like to spend it on
> the important things .. if i need to reallocate memory manually
>   everytime i wanna put 2 strings together of create some kind of output ill
> start dreaming about chars pretty soon ... and i really really
>   dont want THAT to happen ;)

--

CodeWarrior for Palm OS technical lead
Get help at http://palmoswerks.com/

 
 
 

1. Function to parse / split out a sub string from a string ?

Not wishing to re-invent the wheel.  Has anyone produced something like this
before, or any good ideas how I might do it ?

I want a function that takes as its parameters 1-a string (or cell location
where you would expect a string to be), 2-a separator, 3-the position of the
sub string to be returned.

e.g. if the string = aaa-123456-xyz-999.99

and you called the function

=("aaa-123-xyz-999","-",3)

xyz    <= would be returned.

2. EXT2-OS2 ??? (Linux file system)

3. I wanted the NUMBER of bit strings, not the LENGTH of A string

4. uses for Apple III machines

5. Anyway to convert heximal string to unicode string in gvim?

6. Starting DOS apps with c

7. String and Wide Strings

8. DID Behind System 75 PBX

9. can i put a multi-bye character string in a ordinary CORBA IDL string ?

10. The "string" library in the 1.6.24b (lib/string/*.s)

11. WCValSkipListDict<String, String>.forAll() question

12. Octet string versus Hexadecimal string?

13. Adding a V1 community string with a V2c community string