opening a file in a void function

how do you open a file inside of a void function

this is the code i have

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include "vectorUtils.h"

using namespace std;




// Compute the number of calories in one serving of a recipe
void computeCalories (const char* nutrientFileName, const char* recipeFileName);



int main (int argc, char** argv)
{
if (argc != 3)
{
cerr << "Usage: " << argv[0] << " nutrientFile recipeFile" << endl;
return -1;
}

computeCalories (argv[1], argv[2]);
return 0;
}




// Compute the number of calories in one serving of a recipe
void computeCalories (const char* nutrientFileName, const char* recipeFileName)
{

//open first file/ read



//open 2nd file/ read

//compare two data sets

//loop through ingredients (inside recipes)

//look for corresponding ingredients in nutrients

//if found, add calories found times amount

//if not found, set all flag to false/no

//divide total calories by serving size
//print recipe name




}
What is a "void function"? You open a file the same way no matter what the function returns...
my problem right now is that it doesn't get to calling my void function
i need to make argc = 3 so it will skip whats inside the main
If you're using an IDE, you should be able to edit the command line parameters that it executes your program with. If you're running the exe from the command line, just supply the two arguments when you execute the program.
I can only add to void computeCalories, can't mess with anything else
This is not something you do inside the code. Read my post again.
got it thanks
Topic archived. No new replies allowed.