Newsgroups: comp.os.msdos.djgpp From: manni DOT heumann AT gmx DOT de (Manni Heumann) Subject: Re: Convert String to char * References: <7vn6sc$7fh$1 AT nnrp1 DOT deja DOT com> <7vn8q9$bog$1 AT baker DOT cc DOT tut DOT fi> <7voa5q$smh$1 AT canopus DOT cc DOT umanitoba DOT ca> X-Newsreader: News Xpress 2.01 Date: Wed, 03 Nov 1999 09:08:47 GMT NNTP-Posting-Host: dhcp33-114.uni-bielefeld.de Message-ID: <381ffba3.0@news.uni-bielefeld.de> X-Trace: 3 Nov 1999 10:08:51 +0200, dhcp33-114.uni-bielefeld.de Lines: 35 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com In article <7voa5q$smh$1 AT canopus DOT cc DOT umanitoba DOT ca>, "Randy" wrote: >Or .data(), I don't know the difference between that and .c_str() if any. > Both return a C-string (char array). c_str() will return a Null-terminated one. >Forsberg Sakari wrote in message <7vn8q9$bog$1 AT baker DOT cc DOT tut DOT fi>... >>Nicolas Blais wrote: >>> How do I convert a String to a character array *? >> >>errr.... I remember a function c_str() >> >>string tempstring = "hiiohei"; >>char tempchar[20]; >>strcpy( tempchar, tempstring.c_str() ); >> >>just remember to check if the string is short enough >>or use >> >>int CHAR_LENGHT; >>string tempstring = "hiiohei"; >>char tempchar[CHAR_LENGHT+1]; >>strncpy( tempchar, tempstring.c_str(), CHAR_LENGHT ); >>tempchar[CHAR_LENGHT] = '\0'; >> >>or check string size with function size(); >> >>** Sakari Forsberg zacu AT cc DOT tut DOT fi ** >>** Information: finger zacu AT assari DOT cc DOT tut DOT fi ** > > -- Manni