Hi, I need to make a vector that will store a bunch of names for a random name generator. I need to know if I can use a vector to store strings instead of chars.
Like this:
std::vector<std ::string> Name();
So far Ive tried
std::vector<cha r> Name(10);
Name(1) = "bob";
and
std::vector<std ::string> Name(10, "Bob", "joe", "etc");
and many other variations.
Im new to programming, and yes im a student. No this isn't for an assignment. I'd ask my teacher but you know...its a sunday :P
I have been fiddling with this thing for a bit, and can't figure out how to do it.
I know I could use a char array for it, but I want to use vectors and strings now....where I can.
Thanks
Like this:
std::vector<std ::string> Name();
So far Ive tried
std::vector<cha r> Name(10);
Name(1) = "bob";
and
std::vector<std ::string> Name(10, "Bob", "joe", "etc");
and many other variations.
Im new to programming, and yes im a student. No this isn't for an assignment. I'd ask my teacher but you know...its a sunday :P
I have been fiddling with this thing for a bit, and can't figure out how to do it.
I know I could use a char array for it, but I want to use vectors and strings now....where I can.
Thanks
Comment