Q:

Cannot store value into vector struct

So I'm Trying to store a string in this struct:
struct node{
    std::string name;
};

by (roughly) doing this:
int main(int argc, char *argv[]) {
    // ... other code ...

    std::vector<char> chars;
    chars.push_back('n');

    std::vector<node> nodes;
    for(int i = 0; i < argc; i++) {
        nodes.push_back(node());
        for(auto ch : chars) {
            switch(ch) {
                 case 'n': {
                     nodes[i].name = argv[i];
                     break;
                 }
             }
         }
     }

     // ... other code ...

     for(auto n : nodes) {
         std::cout << n.name << '\n';
     }
     return 0;
}

The whole program compiles and runs but without the output of n.name. It seems like it is only setting nodes[i]'s values within its switch block but I'm not sure why this is. When debugging and looking at values in gdb, nodes[i]'s values are set within that switch block's case however, when I look at the whole array (print nodes) it shows I have not set the name field within the struct. When I leave the switch block entirely (on a new iteration of the loop) and look at the value of that node (node[0] for example) I don't see the name value set there either. 
I'm not sure what I'm doing wrong, I'm new to C++ (familiar with C) but it wouldn't make sense that either the argv[i] (which gets casted into a c++ string AND is declared outside the switch's scope) or the new node that gets pushed back at the beginning of the loop iteration goes out of scope.
Any help would be appreciated. Thanks!

A:

I found the issue, it was in the indexing of the nodes in my original code (not shown here).

