c++ - Get all elements but the first as a separate vector -


i'm trying write basic command-line program in c++. while rest of code has problems galore, too, 1 i'm facing this: i've split inputted line pieces, can't figure out how first can pass down line list of arguments command.

if ruby, i'd this, parts array of space-separated arguments command:

command = parts[0] args = parts[1..-1] 

where parts array of bits space-separated.

tl;dr: how can first elements of vector?

if using type makes easier, feel free -- don't think i'll have that trouble porting over.

i've tried using deque, don't want modify parts, pieces of it. i've searched around on site, of questions turn either related solved in way can't use, starts of hacky workaround i'd rather avoid, or totally unrelated.


p.s. i'm not using namespace std, std:: pain type omitted here. please provide in answers, applicable.

p.p.s. i'm (re)starting @ c++ please provide explanation along answer.

tl;dr: how can first elements of vector?

if want vector containing this:

std::vector<int> parts = ...; std::vector<int> args(parts.begin() + 1, parts.end()); 

if want access vector elements start parts.begin()+1 until parts.end().


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -