Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Bug in String/Stream or just misleading documentation?
Re: Bug in String/Stream or just misleading documentation? [message #14021 is a reply to message #14015] Wed, 06 February 2008 21:04 Go to previous message
Werner is currently offline  Werner
Messages: 234
Registered: May 2006
Location: Cologne / Germany
Experienced Member
luzr wrote on Wed, 06 February 2008 18:26

String is zero terminated, but can contain zeroes...

String s; s[s.GetLength()] == 0 is legal operation and is always true.



Thank you for the clarification.

After thinking again I have to admit that there isn't any bug.

When reading the documentation for the first time, I was thinking that

Quote:

void Put(const String& s)
Writes String to the the stream. String can contain zero characters.
s String to write.



means "String may be empty". That was what I wanted to express using the pseudo code "s.GetLength() == 0".

My mistake was that I was trying to build a String with its last character being a '\0' by writing

String str;
str = "xxx\0";


overlooking that the character sequence is actually an array of char which of course sends the trailing '\0' to hell.

Sorry for the hassle.

Werner

 
Read Message
Read Message
Read Message
Previous Topic: Real newbie question about copying values
Next Topic: What does Vector::GetIndex do?
Goto Forum:
  


Current Time: Wed Sep 03 21:32:54 CEST 2025

Total time taken to generate the page: 0.00519 seconds