Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.c++ Subject: Re: assign string to chr* Date: Fri, 29 Jul 2011 15:12:08 +1200 Lines: 16 Message-ID: <99emo8F7uhU1@mid.individual.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Trace: individual.net 5ueHgEwsDq8iv+Ydwx4JUQbw0D7j7XLLjiHzaCmALE66ZGimcn Cancel-Lock: sha1:uNjXSKexYKaWID1Xw9zmPdxF5u8= User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.9) Gecko/20101021 Lightning/1.0b2 Thunderbird/3.1.4 In-Reply-To: Xref: x330-a1.tempe.blueboxinc.net comp.lang.c++:8306 On 07/29/11 02:50 PM, cerr wrote: > hi, > > how do i correctly assign a string to a char*? > If i do it > char *test; > test= "BLABLA"; > I get "warning: deprecated conversion from string constant to ‘char*’" > But strcpy() ot sprintf() doesn't work because there's no room > allocated yet. So do I actually need to allocate space with calloc()/ > malloc()? Either use std::string, const char* or char[]. -- Ian Collins