# Thread: String Vector question

1. ## String Vector question

I'm new to vectors and I saw some syntax I was not familiar with. Text is a vector.

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?

2. >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.

3. That is assuming:
Code:
```#include <string>
#include <vector>
.
.
std::vector<std::string> text;```

4. 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.

5. >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/

6. > 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.

7. Well since the title says "String Vector" I was pretty sure you would understand that its a vector of strings.

Popular pages Recent additions