地狱全部。这个问题让我不知所措,因为我无法弄清楚我做错了什么。我想要的只是收集变量并将它们传递给函数,但是只要输入函数运行的第一个变量,就可以了?
#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;
}
即使没有为第二个变量输入任何内容,这也是我的输出。
[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 . . .