C++ Tutorial/string/string data — различия между версиями
Admin (обсуждение | вклад) м (1 версия: Импорт контента...) |
|
(нет различий)
|
Текущая версия на 13:30, 25 мая 2010
Use char pointer to point to the char array returned from string.data()
<source lang="cpp">#include <iostream> using std::cout; using std::endl;
- include <string>
using std::string; int main() {
string string1( "STRINGS" ); const char *ptr1 = 0; ptr1 = string1.data(); for ( int i = 0; i < string1.length(); i++ ) cout << *( ptr1 + i ); // use pointer arithmetic return 0;
}</source>
STRINGS"