summaryrefslogtreecommitdiffstats
path: root/doc/src
diff options
context:
space:
mode:
authorMartin Smith <msmith@trolltech.com>2010-01-11 12:24:27 (GMT)
committerMartin Smith <msmith@trolltech.com>2010-01-11 12:24:27 (GMT)
commit51078f1ef008c8395ddb76ac2f444daa511a4507 (patch)
tree661afe131d6887114fef8e9a4538100377f3b6e5 /doc/src
parentc26e95adb9777e642c15930ec6fb49251451b443 (diff)
downloadQt-51078f1ef008c8395ddb76ac2f444daa511a4507.zip
Qt-51078f1ef008c8395ddb76ac2f444daa511a4507.tar.gz
Qt-51078f1ef008c8395ddb76ac2f444daa511a4507.tar.bz2
doc: Added clarification about allocating space for the 0 terminator.
Task-number: QTBUG-5121
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/snippets/code/src_corelib_tools_qbytearray.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/doc/src/snippets/code/src_corelib_tools_qbytearray.cpp b/doc/src/snippets/code/src_corelib_tools_qbytearray.cpp
index 736394f..3cd3db8 100644
--- a/doc/src/snippets/code/src_corelib_tools_qbytearray.cpp
+++ b/doc/src/snippets/code/src_corelib_tools_qbytearray.cpp
@@ -401,5 +401,22 @@ QByteArray text = QByteArray::fromHex("517420697320677265617421");
text.data(); // returns "Qt is great!"
//! [45]
+//! [46]
+QString tmp = "test";
+QByteArray text = tmp.toLocal8Bit();
+char *data = new char[text.size()]
+strcpy(data, text.data());
+delete [] data;
+//! [46]
+
+//! [47]
+QString tmp = "test";
+QByteArray text = tmp.toLocal8Bit();
+char *data = new char[text.size() + 1]
+strcpy(data, text.data());
+delete [] data;
+//! [47]
+
}
+