Using Functions(Too few arguments error)

Here is my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
using namespace std;

char wait4User;


void duplicate(int& a, int& b, int& c)
{
     a = a * 2;
     b = b * 2;
     c = c * 2;
     
     cout << "x="   << a << ", y=" << b << ", z=" << c;
}
int main ()
{
    duplicate();
    cin >> wait4User;
    return 0;
}


My error is:
In function 'int main()': too few arguments to function 'void duplicate(int&, int&, int&)' at this point in file.

I'm really not sure what I am doing wrong. All I am trying to do is double all three of my ints and make it say x=(amount of a doubled), y=(amount of b doubled) etc.
double all three of my ints

And where are all of your three ints? I see none.
void duplicate(int& a, int& b, int& c)

I thought you could declare them like that? How else would I do it?
I then give each int a value of themselves times 2 and try and output it
int a value of themselves times 2

And what is their value before you double it, in your opinion? Notice something's missing here?
The function takes three parameters, but you don't pass any when calling the function.
Oh... Wow...
How can I make it work though? I know i need the initial values inside of the void, but the rest of it I don't know now. Sorry about so many questions. I started taking a C++ class at my school, but its a distant learning class and the instructor rarely replies back to messages.
Well, passing values basically works like this:
1
2
int x=2,y=3,z=5;
duplicate(x,y,z);
Thank you, can you check this and see if it is good? It works, but there still seems to be an error for some reason. At least, the line is red.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
using namespace std;

char wait4User;



void duplicate(int& a, int& b, int& c)
{
     a *= 2;
     b *= 2;
     c *= 2;
     

}
int main ()
{
    int x = 4, y = 9, z = 14;
    duplicate(a, b, c);
    cout << "x=" << x << ", y=" << y << ", z=" << z;    
    cin >> wait4User;
    return 0;
}


Edit: Changed the code a bit, made it so x actually equaled x instead of a..
Last edited on
You have three variables x, y, z and trying to pass three non-existing variables a, b, c.
I suggest continuing here: http://mindview.net/Books/TICPP/ThinkingInCPP2e.html
Or here: http://www.learncpp.com/
It works completely now though with the changes I made and what I put into my last post.
x, y and z are supposed to be duplicates of a, b, and c respectively.
Topic archived. No new replies allowed.