I'm new to vectors and I saw some syntax I was not familiar with. Text is a vector.
It appears this is getting the ith string in the vector and the jth character in that string. Is that correct?Code:text[i][j]
I'm new to vectors and I saw some syntax I was not familiar with. Text is a vector.
It appears this is getting the ith string in the vector and the jth character in that string. Is that correct?Code:text[i][j]
>It appears this is getting the ith string in the vector and the jth character in that string. Is that correct?
Assuming text is a vector of string, then yes. Although I guess technically, it'd be the (i+1)th string, and (j+1)th character, but the i and j probably start at 0 anyway, so as long as the for-loops begin at 0, it would index properly.
That is assuming:
Code:#include <string> #include <vector> . . std::vector<std::string> text;
Thanks for clarifying that. For some reason the CS department at my college does not teach anything on vectors so I'm trying to learn it on my own. I had never come across that syntax but its pretty cool.
>For some reason the CS department at my college does not teach anything on vectors
That's too bad. With the Standard Template Library (STL) now a part of the C++ standard library, C++ now has a powerful library. There's strings, vectors (which can be used like arrays), and various containers like stacks, queues, deques, a bitset class for bit manipulation, plus algorithms to go along with these. Check out the book recommendations at the top of this forum for some books that teach this modern stuff. And here are a couple of references:
http://www.cppreference.com
http://www.sgi.com/tech/stl/
> Text is a vector.
A vector of what?
A vector of chars, your answer is wrong
A vector of char vectors, you may be onto something
A vector of std::string, mmmm
Post more code in context if you want better answers.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Well since the title says "String Vector" I was pretty sure you would understand that its a vector of strings.