To: owsim AT emma DOT ruc DOT dk Cc: djgpp AT delorie DOT com Date: Wed, 11 Dec 1996 21:25:25 PST Subject: Re: what about the "\" Message-ID: <19961211.212638.4887.0.Praxis_Beta@juno.com> References: <9612111400 DOT AA05959 AT emma DOT ruc DOT dk> From: praxis_beta AT juno DOT com (Bruce A Locke) On Wed, 11 Dec 1996 15:00:40 +0100 (MET) owsim AT emma DOT ruc DOT dk (Ole Winther) writes: >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? > >Ole Winther > In C\C++ you can think of the "\" as sort of an signal to the compiler to do something. For instance when using the command: printf("Hello World!\n\n"); You have two instances of "\n". The "\" in "\n" tells the compiler that escape character (the signal I mentioned before) is comming up. So in this case the "n" is the escape character that tells the compiler/program to use a "newline." So when your compiler said that their was an unknown escape character, it was complaining that it didn't know what you meant by "\P" -- Which of course is nonsense as far as the compiler is concerned. When you need to actually use the "\" character, you have to use "\\". So try: strcpy( str, "C:\\PT" ); Hope this helps.... =================================================== Bruce Locke Praxis_Beta AT Juno DOT Com -----BEGIN PGP PUBLIC KEY BLOCK----- Version: 2.6.2i mQBtAzKrQH0AAAEDAL1IJ9mZFuOfLJfIcZvoL1UQSlgC/BA+LxoCRkBfAmC28ebR 2Spx81xYIHxXDw7muMVKYDioId2EbLDMF1svJq35Br462neDf9HRMJOFfDPThNbI kIyQ0JGb8+S/kldEFQAFEbQiQnJ1Y2UgTG9ja2UgPEJydWNlX0xvY2tlQEp1bm8u Q29tPg== =XlnX -----END PGP PUBLIC KEY BLOCK-----