Hell all. This problem is driving me up the wall as I cant figure out what i'm doing wrong. All I want is to collect to variables and pass them into a function, however as soon as a input the first variable the function runs?
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
void avg_rain(string, string);
int main()
{
string file, unit;
//Prompt user for file names, and assign to character array
cout << "Please type the file names with extentions that you would like to open, seperate file names with spaces. \nfile name(s) :";
cin >> file;
//Prompt user for measurement unit
cout << "Please type the unit you would like measurments to be converted to (mm, cm, in)\nUnit : ";
cin >> unit;
//execute function with passed through parameters
avg_rain(file, unit);
system("pause");
return 0;
}
void avg_rain(string ffile ,string funit )
{
cout << ffile;
}
Even though don't type anything for the second variable, this is my output.
[OUTPUT:]
Please type the file names with extentions that you would like to open, seperate file names with spaces.
file name(s) :hello world
Please type the unit you would like measurments to be converted to (mm, cm, in)
Unit : hello
Press any key to continue . . .