DEV Community

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

Posted on • Edited 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. Create a simple text file (.txt) using your coding editor. Then, add a few sentences of text to it. Strip any punctuation marks from the words and make them all lowercase letters. Only store a word in the vector if it is not already present.

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 direct message.

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

While many AI coding tools operate as simple command-response systems, Qodo Gen 1.0 represents the next generation: autonomous, multi-step problem-solving agents that work alongside you.

Read full post

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay