www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/12/11:09:40

From: kagel AT quasar DOT bloomberg DOT com
Date: Thu, 12 Dec 1996 10:52:22 -0500
Message-Id: <9612121552.AA08099@quasar.bloomberg.com >
To: owsim AT emma DOT ruc DOT dk
Cc: djgpp AT delorie DOT com
In-Reply-To: <9612111400.AA05959@emma.ruc.dk> (owsim@emma.ruc.dk)
Subject: Re: what about the "\"
Reply-To: kagel AT dg1 DOT bloomberg DOT com

   X-Files: sunday
   X-Dollar-F: owner-djgpp-list AT delorie DOT com
   X-Dollar-G: owner-djgpp-list AT delorie DOT com
   Errors-To: postmaster AT ns1
   From: owsim AT emma DOT ruc DOT dk (Ole Winther)
   Date: Wed, 11 Dec 1996 15:00:40 +0100 (MET)
   X-Mailer: ELM [version 2.4 PL21]
   Mime-Version: 1.0
   Content-Transfer-Encoding: 8bit
   Content-Type: text/plain; charset=ISO-8859-1
   Content-Length: 261

   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?

The last line should be:

   strcpy( str, "C:\\PT" );

In "C" the backslash (\) character is a quote character for special notations
like '\n' for newline and '\r' for carriage return.  To enter an explicit '\'
you must quote it by doubling it: '\\'.

-- 
Art S. Kagel, kagel AT quasar DOT bloomberg DOT com

A proverb is no proverb to you 'till life has illustrated it.  -- John Keats

- Raw text -


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