Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C++, read in a csv file (list.csv). The file is a csv (comma separated values), so you will be looking for , to distinguish

Using C++, read in a csv file (list.csv).

The file is a csv (comma separated values), so you will be looking for , to distinguish the data.

a. If the thing you are reading says item, perform the following

i. Allocate memory for a new object of item type.

ii. Read in the name, price, and bar code (in that order) and set the corresponding members into the new object.

iii. Push the object into the vector of type

format:

int main(int argc, char* argv[]){

if ( argc != 1 ) { cout<<"usage: "<< argv[0] <<" "; } else {

ifstream the_file( argv[1] ); // Always check to see if file opening succeeded if ( !the_file.is_open() ) cout<<"Could not open file "; }

//-------------------------------------

//Rest of code goes here

//--------------------------------------

}

Example of a line in the .csv file:

item,chips,2.53,8.62E+11,dairy, milk,5.69,8.68E+11,11,8,17,45,item,peanut butter,4.99

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

More Books

Students also viewed these Databases questions