From the course: C Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Solution: Transform a file (STL)

Solution: Transform a file (STL) - C Tutorial

From the course: C Essential Training

Solution: Transform a file (STL)

(upbeat music) - [Instructor] Your challenge for this chapter was to read a text file, decode it, store its data in a structure, and print the results all using the STL. Here's my solution. This is 09-solution.cpp from chapter nine of the exercise files. And you notice I'll be using the string class and the vector class. I have here the path to the items.text file, your path will be different. So you'll want pay attention to that. I have a constant for the size of a line buffer. I have a constant for a tab character. I have a class for my structure. Here's the three data members, the sku, the name, and the description. And I have constructors, a destructor, a copy operator, and some getters, and various support methods. This is my copy constructor. This is my copy operator and I have a little function for splitting a string on tabs. You notice while true, I find a tab, I push back a substring onto a vector, and…

Contents