|
From: Ioannis V. <no...@ya...> - 2002-01-11 23:54:31
|
> -----Original Message----- > From: Ioannis Vranos [mailto:no...@ya...] > Sent: Saturday, January 12, 2002 1:54 AM > To: Dev-C++ (dev...@li...) > Subject: RE: [Dev-C++] working with strings > > > > -----Original Message----- > > From: dev...@li... > > [mailto:dev...@li...] On Behalf > > Of Joost van Rooij > > Sent: Friday, January 11, 2002 9:28 AM > > To: dev...@li... > > Subject: [Dev-C++] working with strings > > > > > > Hi, > > > > I am a c++ newbie and I am trying to put to strings together > > but I can't > > seem to figure out how to do it. My previous coding > > experience is in PHP > > where I found this very easy to do... > > > > I would like to do something like this > > > > char firstname [15]; > > char lastname [20]; > > char fullname [35] = (firstname+lastname); > > > > ...But that obviously won't work! Can somebody show me how to > > do such a > > thing? > > In C++ you had better to use the string type and not program > in low level with char arrays. So this is what you can do: > > > #include <stream> i wanted to write: #include <string> > > ... > > using namespace std; > > string s1="string1"; > string s2=" string2"; > string s=s1+s2; > > e.t.c. > > > > Ioannis > > * Ioannis Vranos > * Programming pages: http://www.noicys.d2g.com > * Alternative URL: http://run.to/noicys > |