Hello nvoigt, thank's for your time and help. I find the way to rut it with std::string, but it seems a little confused. That's how it works:
Code:
#include <conio.h>
#include <stdio.h>
#include <vector>
#include <string>
int main()
{
std::string txt="my";
std::vector<std::string>vvv;
vvv.push_back(txt);
txt = "vector";
vvv.push_back(txt);
txt = "test";
vvv.push_back(txt);
std::vector<std::string>::iterator dadesVector;
for(dadesVector = vvv.begin(); dadesVector != vvv.end(); dadesVector++)
{
std::string strD = *(dadesVector);
cout<<strD<<endl;
}
getch();
return 0;
}
It works exactly as I expected. But there's something I still see clearer: the next piece of code gives an error:
Code:
for(int q=0;q<vvv.size();q++)
{
std::string vtxt = vvv.at(q);
cout<<vtxt.c_str()<<endl;
}
The error is:
Code:
no matching function for call to `vector<basic_string<char,string_char_traits<char>,
__default_alloc_template<false,0> >,allocator<basic_string<char,string_char_traits<char>,
__default_alloc_template<false,0> > > >::at (int &)'
I'm doing it in DevCpp with the MingW default compiler.
Where can be the problem? (note: the iterator method to access to data works well, but I would like to know if that's problem of compiler, includes, I don't know whatever else...).
Thank's.
Niara