Feb 26, 2013 at 5:00pm UTC
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
}
Feb 26, 2013 at 5:08pm UTC
What is a "void function"? You open a file the same way no matter what the function returns...
Feb 26, 2013 at 5:14pm UTC
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
Feb 26, 2013 at 5:16pm UTC
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.
Feb 26, 2013 at 5:40pm UTC
I can only add to void computeCalories, can't mess with anything else
Feb 26, 2013 at 5:44pm UTC
This is not something you do inside the code. Read my post again.