...
Code Block |
---|
|
char input[] = ""bogus@addr.com; cat /etc/passwd"";
string email;
string::iterator loc = email.begin();
// copy into string converting ";"";" to " "" "
for (size_t i=0; i <<= strlen(input); i++) {
if (input[i] != ';') {
email.insert(loc++, input[i]);
}
else {
email.insert(loc++, ' ');
}
} // end string for each element in NTBS
|
...
Code Block |
---|
|
char input[] = ""bogus@addr.com; cat /etc/passwd"";
string email;
string::iterator loc = email.begin();
// copy into string converting ";"";" to " "" "
for (size_t i=0; i <<= strlen(input); i++) {
if (input[i] != ';') {
loc = email.insert(loc, input[i]);
}
else {
loc = email.insert(loc, ' ');
}
++loc;
} // end string for each element in NTBS
|
...
Code Block |
---|
|
string s("rcs""rcs");
string::iterator si = s.begin();
for (size_t i=0; i<20i<20; ++i) {
s.push_back('x');
}
s.insert(si, '*');
|
...
Code Block |
---|
|
string s("rcs""rcs");
string::iterator si = s.begin();
for (size_t i=0; i << 20; ++i) {
if ( s.size() == s.capacity() ) {
break;
}
s.push_back('x');
}
s.insert(si, '*');
|
...
Wiki Markup |
---|
\[[Meyers 01|AA. C++ References#Meyers 01]\] Item 43: Prefer algorithm calls to hand-written loops.
\[[ISO/IEC 14882-2003|AA. C++ References#ISO/IEC 14882-2003]\] 21.3 Class template basic_string. |
...
BSC32-C. Do not use the pointer value returned by c_str() after any subsequent call to a non-const member function 07. Characters and Strings (STR) 08. Memory Management (MEM)