delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/02/16:32:58

From: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Help with strings MID$?
Date: 30 Aug 1997 05:20:08 GMT
Organization: The National Capital FreeNet
Lines: 21
Message-ID: <5u8ai8$22o@freenet-news.carleton.ca>
References: <Pine DOT SGI DOT 3 DOT 93 DOT 970829161424 DOT 29363B-100000 AT gibson>
Reply-To: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
NNTP-Posting-Host: freenet3.carleton.ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Orlando Andico (orly AT gibson DOT eee DOT upd DOT edu DOT ph) writes:
> 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!!

Or, leave mystring[7] alone and use strncpy or strncat with 'n' equal to 3.
(And you meant mystring + 4 right? mystring + 0 is the first char, + 4 is
the fifth.)
--
    .*.  Where feelings are concerned, answers are rarely simple [GeneDeWeese]
 -()  <  When I go to the theater, I always go straight to the "bag and mix"
    `*'  bulk candy section...because variety is the spice of life... [me]
Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh

- Raw text -


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