cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/29/04:18:36

Date: Fri, 29 Aug 1997 16:16:49 +0800 (GMT)
From: Orlando Andico <orly AT gibson DOT eee DOT upd DOT edu DOT ph>
To: Erik Max Francis <max AT alcyone DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Help with strings MID$?
In-Reply-To: <340626E7.47A7682F@alcyone.com>
Message-ID: <Pine.SGI.3.93.970829161424.29363B-100000@gibson>
MIME-Version: 1.0

On Thu, 28 Aug 1997, Erik Max Francis wrote:

> Vincent Collura wrote:
> 
> > 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.
> 
> There isn't a standard C function do to this for you.  You're going to
> have to write your own.
..

Ack. I remember when I graduated from Basic to C, I was so pissed off
because there was no mid$/left$/right$ and so forth. until i discovered
The Joy of Pointers (tm)  :)

char *mystring="1234567890";
char *mid3;

to get characters 5..7 (destructively though)
mystring[7] = '\0';  /* chop off 8th character and rest */
mid3 = mystring + 5; /* point to fifth character */

and you're there!!
 
-------------------------------------------------------------------
Orlando Alcantara Andico
WWW:   http://www2.mozcom.com/~orly/         Email: orly AT mozcom DOT com
ICBM:  14 30 00 N  120 59 00 E               POTS:  (+632) 932-2385

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019