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] <<"
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started