C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: zwei char * miteinander verbinden

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German)
View previous topic :: View next topic  
Author Message
Georg Maaß
Guest





PostPosted: Sun Sep 26, 2004 1:38 pm    Post subject: Re: zwei char * miteinander verbinden Reply with quote



Sascha Bajonczak wrote:
Quote:
Hallo Ng,

bin noch recht neu auf den gebiet der c++ Programmierung.

Nun habe ich ja vorher nur in VB gearbeitet dort konnte ich "Strings"
mit einder verbindern indem ich

string_result= string1 & string2

geschrieben habe.


Nur wie funktioniert sowas in c++?

std::string s1,s2, s3;
s3 = s1 + s2;

oder

s3 = s1;
s3 += s2;

Quote:
ich nehme mal an char* ist sowas wie nen String obwohl es nur ein Zeiger
auf eine Speicherstelle ist wo sich der "String" befindet.

Nein, char* ist kein String, sondern die Adresse eines char. Oftmals ist
dieser char jedoch einfach nur der erste char aus einer Folge von char,
die z.B. durch einen '' char terminiert sind. Solch eine Folge nennt
man C-String. Solche Dinger sind die Vorstufe zum Bufferoverflow. Bei
einem std::string dagegen gibt es keinen Bufferoverflow, sondern
allenfalls eine Exception, wenn der Speicher ausgeht. AUf Exceptions
kann man reagieren, auf Bufferoverflow nur noch abstürzen.


--
Georg Maaß - bioshop.de D-76227 Karlsruhe, Westmarkstraße 82
HTML, XML / JavaScript, C++, Java, PHP, VB / CGI, JSP, ASP, ASP.net
- The ultimate DHTML engine: http://gml-modul.sourceforge.net -
http://sourceforge.net/projects/gml-modul

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.