C++ basics for competitive programming
First important mistake, <i>By the way, vector is the only container that is backward-compatible to native C code – this means that vector actually IS the array, but with some additional features.</i><p>No, it is not.  A C array under the hood is a pointer to the start of the array.  A vector is a data structure that includes a pointer to the start of an array.  This is needed because that data structure is where it includes things like the size.  But you can easily get out the array pointer, so no big deal, right?  Wrong.<p>The problem is that there are vector operations which do weird stuff with the array.  For example suppose you pass the array to one data structure, then push_back on the vector.  The vector may now realize it doesn&#x27;t have enough room to add more data, so moves the actual array to a new location and frees the old.<p>You may not realize this because the freed array still contains something that looks like the array.  But it isn&#x27;t any more!<p>Want another fun difference?  In C programming you can easily allocate arrays in an mmapped block backed by a file,  exit, then do another run and simply load the mmapped block.  Try that with a vector and you&#x27;ll get metadata pointing at random memory that you haven&#x27;t allocated.  BOOM!<p>So it is really wrong to say that a vector IS just a C array with extra features.  They are different, and the differences can bite you pretty hard.<p>(That&#x27;s the point I decided that continuing with this article was more likely to mislead than be helpful for me.)