www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/13/00:41:05

From: "A. Sinan Unur" <asu1 AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: what about the "\"
Date: Thu, 12 Dec 1996 12:36:24 -0500
Organization: Cornell University http://www.cornell.edu
Lines: 26
Sender: asu1 AT cornell DOT edu (Verified)
Message-ID: <32B04298.50A9@cornell.edu>
References: <9612111400 DOT AA05959 AT emma DOT ruc DOT dk>
Reply-To: asu1 AT cornell DOT edu
NNTP-Posting-Host: cu-dialup-0014.cit.cornell.edu
Mime-Version: 1.0
To: Ole Winther <owsim AT emma DOT ruc DOT dk>
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Ole Winther wrote:
> 
> Well some small problems
> 
> I where trying this.
> 
> char* str;
> str = new char[5];
> strcpy( str, "C:\PT" );
> 
> and printing this gives ( C:PT  ), the "\" is stripped. when compiling the
> programs there complains about and unknown escape char. How to do it?

several other people have indicated the solution to your direct
question. however, there is another problem with this code. you str does
not have enough room to contain both "C:\\PT" and the end of string
marker '\0'.

-- 
*******************************************************************
 A. Sinan Unur                                WWWWWW
                                              |--O+O
 mailto:asu1 AT cornell DOT edu                      C   ^ 
 mailto:sinan AT econ DOT cit DOT cornell DOT edu             \  ~/ 
 http://www.bqnet.com/sinan/
*******************************************************************

- Raw text -


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