using (importing and saving) csv files
Hey all, for my next (and last, about time) assignment, my professor is asking us to try and use/manipulate csv files (specifically to import, manipulate, and finally save). This is the first time in the semester that we're playing around with them, and I'm not a bit clueless as to where to begin. Would it be similar to opening and closing regular files? If I already wrote something like this:
Code:
if (argc != 3) //if there are an incorrect number of arguments
{
cerr << "\n\tIncorrect usage.\n"
<< "\tCorrect syntax: " << argv[0] << " inputFile outPutFile\n\n";
exit(1);
}
ifstream fin;
ofstream fout;
fin.open (argv[1]); //opens input file from command line
if (fin.fail()) //if file cannot open
{
cerr << "Could not open " <<argv[1] << endl;
exit(1);
}
fout.open (argv[2]);
if (fout.fail()) //if file cannot open
{
cerr << "Could not open " <<argv[2] << endl;
exit(1);
}
//main program, using fin and fout
fin.close();
fout.close();
Would this be able to provide a template for using csv files? Or do I need to learn new syntax? Thanks in advance for your troubles!