| delorie.com/archives/browse.cgi | search | 
| From: | Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk> | 
| Newsgroups: | comp.os.msdos.djgpp | 
| Subject: | Re: Extracting a directory name. | 
| Date: | Mon, 18 Jun 2001 20:35:13 +0100 | 
| Lines: | 22 | 
| Message-ID: | <3B2E57F1.FCADB9AF@phekda.freeserve.co.uk> | 
| References: | <u0pX6.32176$9t5 DOT 2935940 AT news6-win DOT server DOT ntlworld DOT com> <7458-Mon18Jun2001185556+0300-eliz AT is DOT elta DOT co DOT il> <SYpX6.32438$9t5 DOT 2956364 AT news6-win DOT server DOT ntlworld DOT com> | 
| NNTP-Posting-Host: | modem-96.erythromycin.dialup.pol.co.uk | 
| Mime-Version: | 1.0 | 
| X-Trace: | newsg3.svr.pol.co.uk 992893346 29711 62.136.93.96 (18 Jun 2001 19:42:26 GMT) | 
| NNTP-Posting-Date: | 18 Jun 2001 19:42:26 GMT | 
| X-Complaints-To: | abuse AT theplanet DOT net | 
| X-Mailer: | Mozilla 4.77 [en] (X11; U; Linux 2.2.19 i586) | 
| X-Accept-Language: | de,fr | 
| To: | djgpp AT delorie DOT com | 
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp | 
| Reply-To: | djgpp AT delorie DOT com | 
Hello.
Graham Reeds wrote:
> > Did you consider the possibility that strncpy might not null-terminate
> > the resulting string in BaseDir?
> 
> I did, and tried to append one with strcat, but that didn't solve the
> problem.
You won't be able to append a nul using strcat(). If there's no nul on the
end of the string, how do you determine how long it is? (Hint: nul is the
terminating character for a string in C.) You will have to write the nul
in the char array yourself, e.g.:
    strncpy(dest, src, len);
    dest[len] = '\0';
HTH, bye,
-- 
Richard Dawe
http://www.phekda.freeserve.co.uk/richdawe/
| webmaster | delorie software privacy | 
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |