A
Adrian
Hi all,
I want a char * (not const) from a std::string.
I see string.begin() return an iterator which is implementation
defined.
And *iterator returns a reference to the element
So does &*iterator return a pointer to the element?
Now this below compiles but is it legal?
Adrian
#include <iostream>
#include <string>
#include <locale>
int main(int argc, char *argv[])
{
std::string mixed("We ARE a test String");
std::cout << mixed << std::endl;
// What is a good way to get the pointer from an iterator
// Are you allowed to do this?
ctype.tolower(&*mixed.begin(), &*mixed.end());
std::cout << mixed << std::endl;
// instead of this
ctype.toupper(&mixed[0], &mixed[mixed.length()]);
std::cout << mixed << std::endl;
return 0;
}
I want a char * (not const) from a std::string.
I see string.begin() return an iterator which is implementation
defined.
And *iterator returns a reference to the element
So does &*iterator return a pointer to the element?
Now this below compiles but is it legal?
Adrian
#include <iostream>
#include <string>
#include <locale>
int main(int argc, char *argv[])
{
std::string mixed("We ARE a test String");
const std::ctype said:(std::locale::classic());
std::cout << mixed << std::endl;
// What is a good way to get the pointer from an iterator
// Are you allowed to do this?
ctype.tolower(&*mixed.begin(), &*mixed.end());
std::cout << mixed << std::endl;
// instead of this
ctype.toupper(&mixed[0], &mixed[mixed.length()]);
std::cout << mixed << std::endl;
return 0;
}