Mail Archives: djgpp/1997/09/03/02:18:02
Vincent Collura wrote:
>
> Hello,
>
> I am new to C++ and am trying to convert a
> old QuickBasic utiltiy I wrote into C++. It
> compiles fine except I still cant figure how
> to convert this Basic statement
>
> tally(item) = MID$(touch$, 2, 5) + MID$(touch$, 41, 12) + MID$(touch$, 73,
> 7)
>
> Into c++, For those who dont know, mid$ returns the
> n'th character to the nth number.
>
> What is the C++ function to do this? I have
> tried StrnCat but the problem with this is you
> cant specificy a starting location.
One way of doing it is to use the GNU C++ class library libgpp.a's
String class. The String class has a member function called at(). Your
BASIC code could be translated to:
String touch, tally;
tally = touch.at(2,5) + touch.at(4,12) + touch.at(73,7);
Look up the GNU C++ class library info file: "info libgpp String".
You might also want to check out the third edition of The C++ Language,
which describes the standard C++ library. (I haven't checked, but) I
imagine there would be an ANSI C++ String class that has a member
function that does exactly what the String::at() function does.
--
Weiqi Gao
weiqigao AT a DOT crl DOT com
- Raw text -