Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums
Members
Pages
Search
Help
Register
Login
Home
Home
»
U++ Library support
»
U++ Core
»
Bug in String/Stream or just misleading documentation?
Show:
Today's Messages
::
Show Polls
::
Message Navigator
E-mail to friend
Bug in String/Stream or just misleading documentation?
[
message #14014
]
Wed, 06 February 2008 18:19
Werner
Messages:
234
Registered:
May 2006
Location:
Cologne / Germany
Experienced Member
String documentation says that String contains an array of characters which is zero-terminated. This suggests that a String cannot contain '\0's.
On the other hand Stream documentation says:
Quote:
void Put(const String& s)
Writes String to the the stream. String can contain zero characters.
s String to write.
This can either mean that s can indeed contain '\0's or that "s.GetLength() == 0" is valid.
While the latter case seems trivial to me, the first case doesn't work as outputting a String with an appended '\0' swallows the trailing '\0'.
So, what is correct?
No '\0's inside a String and "a_stream.Put("");" is valid?
Or '\0's inside a String are valid and "Put(const String& s)" is buggy?
Werner
Report message to a moderator
Re: Bug in String/Stream or just misleading documentation?
[
message #14015
is a reply to
message #14014
]
Wed, 06 February 2008 18:26
mirek
Messages:
14255
Registered:
November 2005
Ultimate Member
String is zero terminated, but can contain zeroes...
String s; s[s.GetLength()] == 0 is legal operation and is always true.
Mirek
Report message to a moderator
Re: Bug in String/Stream or just misleading documentation?
[
message #14021
is a reply to
message #14015
]
Wed, 06 February 2008 21:04
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
Report message to a moderator
Previous Topic:
Real newbie question about copying values
Next Topic:
What does Vector::GetIndex do?
Goto Forum:
- Community
U++ community news and announcements
PR, media coverage, articles and documentation
U++ Webs: Functioning, Layout , Design, Features and Structure of these forums, homepage etc.
Coffee corner
Newbie corner
U++ based job offers
- Developing U++
U++ Developers corner
External resources
Releasing U++
UppHub
Bugs (& fixes)
Documentation
U++ TheIDE and Library: Releases and ChangeLogs
Mac OS
Android
- U++ Library support
U++ Library : Other (not classified elsewhere)
U++ Core
Look and Chameleon Technology
U++ Libraries and TheIDE: i18n, Unicode and Internationalization
U++ SQL
U++ MT-multithreading and servers
U++ Callbacks and Timers
U++ Widgets - General questions or Mixed problems
TopWindow&PopUp, TrayIcon
Menus&Toolbars
StatusBar&InfoCtrl
Splitter
TabCtrl
Slider&ProgressIndicator
ArrayCtrl, HeaderCtrl & GridCtrl
TreeCtrl
RichText,QTF,RTF...
LineEdit, EditFields, DocEdit
Draw, Display, Images, Bitmaps, Icons
FileSel&FileList, Path
CalendarCtrl
Skylark
ScatterDraw & ScatterCtrl
Archive
- U++ TheIDE
U++ TheIDE: Other Features Wishlist and/or Bugs
U++ TheIDE: Compiling, Linking, Debugging of your packages
U++ TheIDE: Installation, Compiling and Running of theide
U++ TheIDE: CodeEditor, Assist++, Topic++
U++ TheIDE: Packages
U++ TheIDE: Layout (Forms) Designer
U++ TheIDE: Icon designer
- Extra libraries, Code snippets, applications etc.
U++ users applications in progress and useful code snippets, including reference examples!
U++ Esc Interpreter, Esc Macros and templates
C++ language problems and code snippets
Applications created with U++
OS Problems etc., Win32, POSIX, MacOS, FreeBSD, X11 etc
-=]
Back to Top
[=-
[
Syndicate this forum (XML)
] [
] [
]
Current Time:
Sun Apr 27 22:14:56 CEST 2025
Total time taken to generate the page: 0.00647 seconds