Calling a function- primary expression?

I'm working on a simple program that will calculate a total number of days depending on the number of days and weeks the user enters. When I call my function in int main(), it says "expected primary-expression before 'int'". I'm new to C++ syntax and came over from Java, what am I missing? (If that's even the problem)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  void giveDays(int days, int weeks)
{
	cout << "How many days? ";
	cin >> days;
	cout << "How many weeks? ";
	cin >> weeks;
	
	weeks = weeks * 7;
	int totalDays = days + weeks;
	
	cout << days << " days" << endl;
	cout << weeks << " weeks" << endl;
	cout << "has " << totalDays << "total days\n";
}

int main()
{
	giveDays(int days, int weeks);
	system("PAUSE");			//pause for viewing data
	return 0;
}
Last edited on
this is the prototype of system() int system(const char *command);
this is how you called it system("PAUSE");
that way, `command' will take the value "PAUSE" and the function will do something with that.

now you have the function void giveDays(int days, int weeks)
so you may call it giveDays(54, 13);
then `days' will take the value 54 and `weeks' will take 13

... and then you just simply discard those value and use the user input...


as an advice, try to avoid doing input/output operations inside functions, limit that to main()
hopefully you'll understand what's the porpuse of parameters and return value.
ah, I see. Thanks!
Topic archived. No new replies allowed.