Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!