From: sherlock AT pratique DOT fr Newsgroups: comp.os.msdos.djgpp Subject: Re: what about the "\" Date: Sun, 15 Dec 1996 15:09:39 GMT Organization: Internet Way Lines: 32 Message-ID: <5910ku$i59@s3.iway.fr> References: <9612111400 DOT AA05959 AT emma DOT ruc DOT dk> NNTP-Posting-Host: max1-17.ystel.fr To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp owsim AT emma DOT ruc DOT dk (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? >Ole Winther There are two problems here: - The character '\' has special mening in C. You have to put it twice to use it in strings constants. the line would become : strcpy(str,"c:\\PT"); - You declare an array of five characters, and the length of the string "C:\PT" is five characters PLUS the character '\0' needed at the end of the string ie SIX characters. strcpy will append it, and probably will crash. Hope this help