DEV Community

Cover image for Programming in C++ (Part 6 Vectors)
Mark Mahoney
Mark Mahoney

Posted on

Programming in C++ (Part 6 Vectors)

C++ comes with the Standard Template Library (STL) which is a collection of different containers. This post will cover vectors. A vector is an array-based container that holds data very much like an array does but it is smarter. It knows how many elements are in it and it can grow as the program is running. I also show how to read and write data from a file, efficiently search through an array-based container, sort values, and more.

Call to Action

Now that you have reviewed the guided code walk-throughs I ask that you write a program to read in whole words from a file and store them in a vector of strings. Only store a word in the vector if it is not already present. Strip any punctuation marks from the words and make them all lowercase letters.

Comments and Feedback

You can find all of these code playbacks in my free 'book', An Animated Introduction to Programming in C++. I am always looking for feedback so please feel free to comment here or to send me a message. You can follow me on twitter @markm208.

Discussion (0)