0

I am currently trying to split a string and store it into a vector.

For example,

std::string argData = "1:/path/to/file, 3:/path/to/differentfile, 4:/path/to/anotherfile";
vector<string> v = Util::split(argData, ",");

will return ["1:/path/to/file", "3:/path/to/differentfile", "4:/path/to/anotherfile"] in v.

What I would like to do is:

for each string in vector 
position = string.find(':')

How would I do this in C++? I do not have access to C++11 for auto.

1201ProgramAlarm
  • 32,384
  • 7
  • 42
  • 56
  • Explore `std::stringstream` facilities. – Ron Jan 22 '18 at 14:45
  • Possible duplicate:https://stackoverflow.com/questions/409348/iteration-over-stdvector-unsigned-vs-signed-index-variable – sma Jan 22 '18 at 14:45
  • 2
    Possible duplicate of [How do I Iterate over a vector of C++ strings?](https://stackoverflow.com/questions/11170349/how-do-i-iterate-over-a-vector-of-c-strings) – karastojko Jan 22 '18 at 14:48
  • Vectors without c++11? You could try using [`std::list`](http://www.cplusplus.com/reference/list/list/). About the "find"-part, there is a function [`std::string::find()`](http://www.cplusplus.com/reference/string/string/find/) – Detonar Jan 22 '18 at 14:53
  • 2
    @Detonar Vectors are in c++98 – UKMonkey Jan 22 '18 at 15:05

0 Answers0