delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/06/12:33:18

From: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Help with strings MID$?
Date: 3 Sep 1997 06:01:20 GMT
Organization: The National Capital FreeNet
Lines: 17
Message-ID: <5uiufg$stq@freenet-news.carleton.ca>
References: <Pine DOT SUN DOT 3 DOT 95 DOT 970902195216 DOT 19406A-100000 AT ernie DOT eecs DOT uic DOT edu>
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

Andrew Deren (aderen AT eecs DOT uic DOT edu) writes:
> But where are you going to copy it to?
> mid3 is just a pointer pointint somewhere to your memory. if you want
> to use strncpy you first have to allocate memory for mid3.

Setting mid3=mystring+4 points mid3 at memory just past mystring. This
will work for strcat/strcpy so long as mystring is itself allocated,
points to a zero-terminated string and has 4 or more characters (so the
null is at or past mid3). So will strncat and strncpy, since they copy UP
TO 'n' characters, less if they find a null first.

--
    .*.  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