I'm supposed to use a 'top-down' programming style (which is my enemy) for a simple game of Cootie, and I am very new to C++ so there will be errors abound in my program, I'm just working on getting past one error thus far:

void ApplyRoll(int Roll, int Body, int Head, int Antennae, int Legs, int Eyes, int Lips);

It generates an error in Dev C++:

too few arguments to function `void ApplyRoll(int, int, int, int, int, int, int)'
at this point in file

Here is the complete code:

// Re-writing the Cootie program using top-down design
// Top-down programming is not my friend

#include <iostream> // use input/output functionality - STILL NEEDED??
#include <cstdlib> // for rand
#include <conio.h> // for Y/N input

using namespace std;
    
int main() {
    srand((unsigned)time(0));
    
    int Roll, Body, Head, Antennae, Legs, Lips, Eyes;
    
    int RollDice();
    void AddBody(int Body);
    void AddHead(int Body, int Head);
    void AddAntennae(int Body, int Head, int Antennae);
    void AddEyes(int Body, int Head, int Eyes);
    void AddLegs(int Body, int Head, int Legs);
    void AddLips(int Body, int Head, int Lips);
    void ApplyRoll(int Roll, int Body, int Head, int Antennae, int Legs, int Eyes, int Lips);
    string PrintCootie(int Body, int Head, int Antennae, int Legs, int Eyes, int Lips);
    
    do {
        Roll = RollDice();
        ApplyRoll(Roll);
        PrintCootie(Body, Head, Antennae, Legs, Lips, Eyes);
    while (!CootieComplete(1)) ;
}

/*** functions ***/
int RollDice() {
// roll the dice and return value
    return rand() % 6 + 1;
}

void ApplyRoll(int Roll, int Body, int Head, int Antennae, int Legs, int Eyes, int Lips) {
// add the corresponding Cootie piece from the roll
    if(Roll == 1) {
        AddBody(Body);
    }
    else if(Roll == 2) {
        AddHead(Body, Head);
    }
    else if(Roll == 3) {
        AddAntennae(Body, Head, Antennae);
    }
    else if(Roll == 4) {
        AddEyes(Body, Head, Eyes);
    }
    else if(Roll == 5) {
        AddLips(Body, Head, Lips);
    }
    else if(Roll == 6) {
        AddLegs(Body, Head, Legs);
    }
}

// add parts
int AddBody(int Body) {
// need body first
    if(Body < 1) {
        Body++;
    }
}

int AddHead(int Body, int Head) {
// then head
    if(Head < 1 && Body == 1) {
        Head++;
    }
}

int AddAntennae(int Body, int Head, int Antennae) {
    if(Antennae < 1 && Head == 1 && Body == 1) {
        Antennae++;
    }
}

int AddEyes(int Body, int Head, int Eyes) {
    if(Eyes < 1 && Head == 1 && Body == 1) {
        Eyes++;
    }
}

int AddLips(int Body, int Head, int Lips) {
    if(Lips < 1 && Head == 1 && Body == 1) {
        Lips++;
    }
}

int AddLegs(int Body, int Head, int Legs) {
    if(Legs < 6 && Head == 1 && Body == 1) {
        Legs++;
    }
}

string PrintCootie(int Body, int Head, int Antennae, int Legs, int Lips, int Eyes) {
// pieces in the Cootie so far  
    cout << "Cootie has ";

    if(Body == 1) {
        cout << "body ";
    }
    if(Head == 1) {
        cout << "head ";
    }
    if(Antennae == 1) {
        cout << "antennae ";
    }
    if(Legs < 6) {
        cout << "legs(" << Legs << ") ";
    }
    if(Lips == 1) {
        cout << "lips ";
    }
    if(Eyes == 1) {
        cout << "eyes";
    }
    
    cout << "." << endl; 
}

CootieComplete() {
// return 1=finished, 0=incomplete
    if (Body == 1 && Head == 1 && Antennae == 1 && Legs == 6 && Lips == 1 && Eyes == 1) {
        return 1;
    }
    else {
        return 0;
    }
}

I appreciate help!

The error message says it all.
ApplyRoll expects seven arguments, but you're just passing one.

I've had several errors with your code :

time isn't declared, CootieComplete function is missing, etc.

And he's not passing one, he's passing seven, so I can't get it...

Line 27. He passes a single argument.

Oh, that one, sorry. (:

Well, then one plus error. :P

CootieComplete function isn't missing, just badly declared at the end of the file (no return type and incorrect parameter list).

time is a function declared in ctime header library which is missing from this code sample.

I get it, but I've copy-pasted it to CodeBlocks and that's how I got these errors. Ah well, nevermind. :)

Thank you guys =] Can't believe I didn't see that first of all. Will update if I come across anything else.

I've made some adjustments, but am stuck on how to put it all together. I get a bunch of undeclared function errors- this is probably basic, but can I not call a function from within a function? (See ApplyRoll function). The CootieComplete function I am clueless with also. Do any of you have ideas of how to complete the program?

Here's the code:

// Re-writing the Cootie program using top-down design
// Top-down programming is not my friend

#include <iostream> // use input/output functionality - STILL NEEDED??
#include <cstdlib> // for rand
#include <conio.h> // for Y/N input
#include <ctime>

using namespace std;
    
int main() {
    srand((unsigned)time(0));
    
    int Roll, Body, Head, Antennae, Legs, Lips, Eyes;
    
    int RollDice();
    void AddBody(int Body);
    void AddHead(int Body, int Head);
    void AddAntennae(int Body, int Head, int Antennae);
    void AddEyes(int Body, int Head, int Eyes);
    void AddLegs(int Body, int Head, int Legs);
    void AddLips(int Body, int Head, int Lips);
    void ApplyRoll(int Roll, int Body, int Head, int Antennae, int Legs, int Eyes, int Lips);
    string PrintCootie(int Body, int Head, int Antennae, int Legs, int Eyes, int Lips);
    bool CootieComplete();
    
    do {
        Roll = RollDice();
        ApplyRoll(Roll, Body, Head, Antennae, Legs, Eyes, Lips);
        PrintCootie(Body, Head, Antennae, Legs, Lips, Eyes);
    }
    while (!CootieComplete());
}

/*** functions ***/
int RollDice() {
// roll the dice and return value
    return rand() % 6 + 1;
}

void ApplyRoll(int Roll, int Body, int Head, int Antennae, int Legs, int Eyes, int Lips) {
// add the corresponding Cootie piece from the roll
    if(Roll == 1) {
        AddBody(Body);
    }
    else if(Roll == 2) {
        AddHead(Body, Head);
    }
    else if(Roll == 3) {
        AddAntennae(Body, Head, Antennae);
    }
    else if(Roll == 4) {
        AddEyes(Body, Head, Eyes);
    }
    else if(Roll == 5) {
        AddLips(Body, Head, Lips);
    }
    else if(Roll == 6) {
        AddLegs(Body, Head, Legs);
    }
}

// add parts
int AddBody(int Body) {
// need body first
    if(Body < 1) {
        Body++;
    }
}

int AddHead(int Body, int Head) {
// then head
    if(Head < 1 && Body == 1) {
        Head++;
    }
}

int AddAntennae(int Body, int Head, int Antennae) {
    if(Antennae < 1 && Head == 1 && Body == 1) {
        Antennae++;
    }
}

int AddEyes(int Body, int Head, int Eyes) {
    if(Eyes < 1 && Head == 1 && Body == 1) {
        Eyes++;
    }
}

int AddLips(int Body, int Head, int Lips) {
    if(Lips < 1 && Head == 1 && Body == 1) {
        Lips++;
    }
}

int AddLegs(int Body, int Head, int Legs) {
    if(Legs < 6 && Head == 1 && Body == 1) {
        Legs++;
    }
}

string PrintCootie(int Body, int Head, int Antennae, int Legs, int Lips, int Eyes) {
// pieces in the Cootie so far  
    cout << "Cootie has ";

    if(Body == 1) {
        cout << "body ";
    }
    if(Head == 1) {
        cout << "head ";
    }
    if(Antennae == 1) {
        cout << "antennae ";
    }
    if(Legs < 6) {
        cout << "legs(" << Legs << ") ";
    }
    if(Lips == 1) {
        cout << "lips ";
    }
    if(Eyes == 1) {
        cout << "eyes";
    }
    
    cout << "." << endl; 
}

bool CootieComplete() {
// return 1=finished, 0=incomplete
    if (Body == 1 && Head == 1 && Antennae == 1 && Legs == 6 && Lips == 1 && Eyes == 1) {
        return 1;
    }
    else {
        return 0;
    }
}

Thank you!

Doh... function types different.

The program runs now, it just keeps going and going though. I'm not sure how to finish it :x
I'm guessing it has something to do with passing by reference with the functions (&)

// Re-writing the Cootie program using top-down design
// Top-down programming is not my friend

#include <iostream> // use input/output functionality - STILL NEEDED??
#include <cstdlib> // for rand
#include <conio.h> // for Y/N input
#include <ctime>

using namespace std;
    
int main() {
    srand((unsigned)time(0));
    
    int Roll, Body, Head, Antennae, Legs, Lips, Eyes;
    
    int RollDice();
    void AddBody(int Body);
    void AddHead(int Body, int Head);
    void AddAntennae(int Body, int Head, int Antennae);
    void AddEyes(int Body, int Head, int Eyes);
    void AddLegs(int Body, int Head, int Legs);
    void AddLips(int Body, int Head, int Lips);
    void ApplyRoll(int Roll, int Body, int Head, int Antennae, int Legs, int Eyes, int Lips);
    string PrintCootie(int Body, int Head, int Antennae, int Legs, int Eyes, int Lips);
    bool CootieComplete(int Body, int Head, int Antennae, int Legs, int Lips, int Eyes);
    
    do {
        Roll = RollDice();
        ApplyRoll(Roll, Body, Head, Antennae, Legs, Eyes, Lips);
        PrintCootie(Body, Head, Antennae, Legs, Lips, Eyes);
    }
    while (!CootieComplete(Body, Head, Antennae, Legs, Lips, Eyes));
}

/*** functions ***/
int RollDice() {
// roll the dice and return value
    return rand() % 6 + 1;
}

// add parts
void AddBody(int Body) {
// need body first
    if(Body < 1) {
        Body++;
    }
}

void AddHead(int Body, int Head) {
// then head
    if(Head < 1 && Body == 1) {
        Head++;
    }
}

void AddAntennae(int Body, int Head, int Antennae) {
    if(Antennae < 1 && Head == 1 && Body == 1) {
        Antennae++;
    }
}

void AddEyes(int Body, int Head, int Eyes) {
    if(Eyes < 1 && Head == 1 && Body == 1) {
        Eyes++;
    }
}

void AddLips(int Body, int Head, int Lips) {
    if(Lips < 1 && Head == 1 && Body == 1) {
        Lips++;
    }
}

void AddLegs(int Body, int Head, int Legs) {
    if(Legs < 6 && Head == 1 && Body == 1) {
        Legs++;
    }
}

void ApplyRoll(int Roll, int Body, int Head, int Antennae, int Legs, int Eyes, int Lips) {
// add the corresponding Cootie piece from the roll
    if(Roll == 1) {
        AddBody(Body);
    }
    else if(Roll == 2) {
        AddHead(Body, Head);
    }
    else if(Roll == 3) {
        AddAntennae(Body, Head, Antennae);
    }
    else if(Roll == 4) {
        AddEyes(Body, Head, Eyes);
    }
    else if(Roll == 5) {
        AddLips(Body, Head, Lips);
    }
    else if(Roll == 6) {
        AddLegs(Body, Head, Legs);
    }
}

string PrintCootie(int Body, int Head, int Antennae, int Legs, int Lips, int Eyes) {
// pieces in the Cootie so far  
    cout << "Cootie has ";

    if(Body == 1) {
        cout << "body ";
    }
    if(Head == 1) {
        cout << "head ";
    }
    if(Antennae == 1) {
        cout << "antennae ";
    }
    if(Legs < 6) {
        cout << "legs(" << Legs << ") ";
    }
    if(Lips == 1) {
        cout << "lips ";
    }
    if(Eyes == 1) {
        cout << "eyes";
    }
    
    cout << "." << endl; 
}

bool CootieComplete(int Body, int Head, int Antennae, int Legs, int Lips, int Eyes) {
// return 1=finished, 0=incomplete
    if (Body == 1 && Head == 1 && Antennae == 1 && Legs == 6 && Lips == 1 && Eyes == 1) {
        return 1;
    }
    else {
        return 0;
    }
}

Phew figured it out.

// Re-writing the Cootie program using top-down design
// Top-down programming is not my friend

#include <iostream> // use input/output functionality - STILL NEEDED??
#include <cstdlib> // for rand
#include <conio.h> // for Y/N input
#include <ctime>

using namespace std;
    
int main() {
    srand((unsigned)time(0));
    
    int Roll, Body=0, Head=0, Antennae=0, Legs=0, Lips=0, Eyes=0;
    
    int RollDice();
    void AddBody(int &Body);
    void AddHead(int &Body, int &Head);
    void AddAntennae(int &Body, int &Head, int &Antennae);
    void AddEyes(int &Body, int &Head, int &Eyes);
    void AddLegs(int &Body, int &Head, int &Legs);
    void AddLips(int &Body, int &Head, int &Lips);
    void ApplyRoll(int Roll, int &Body, int &Head, int &Antennae, int &Legs, int &Eyes, int &Lips);
    string PrintCootie(int &Body, int &Head, int &Antennae, int &Legs, int &Eyes, int &Lips);
    bool CootieComplete(int &Body, int &Head, int &Antennae, int &Legs, int &Lips, int &Eyes);
    
    do {
        Roll = RollDice();
        ApplyRoll(Roll, Body, Head, Antennae, Legs, Eyes, Lips);
        PrintCootie(Body, Head, Antennae, Legs, Lips, Eyes);
    }
    while (!CootieComplete(Body, Head, Antennae, Legs, Lips, Eyes));
    
    system("PAUSE");
    exit(1);
}

/*** functions ***/
int RollDice() {
// roll the dice and return value
    return rand() % 6 + 1;
}

// add parts
void AddBody(int &Body) {
// need body first
    if(Body < 1) {
        Body++;
    }
}

void AddHead(int &Body, int &Head) {
// then head
    //cout << "Head" << endl;
    if(Head < 1 && Body == 1) {
        Head++;
        //cout << Head << endl;
    }
}

void AddAntennae(int &Body, int &Head, int &Antennae) {
    //cout << "Antennae" << endl;
    if(Antennae < 1 && Head == 1 && Body == 1) {
        Antennae++;
        //cout << Antennae << endl;
    }
}

void AddEyes(int &Body, int &Head, int &Eyes) {
    //cout << "Eyes" << endl;
    if(Eyes < 1 && Head == 1 && Body == 1) {
        Eyes++;
        //cout << Eyes << endl;
    }
}

void AddLips(int &Body, int &Head, int &Lips) {
    //cout << "Lips" << endl;
    if(Lips < 1 && Head == 1 && Body == 1) {
        Lips++;
        //cout << Lips << endl;
    }
}

void AddLegs(int &Body, int &Head, int &Legs) {
    //cout << "Legs" << endl;
    if(Legs < 6 && Head == 1 && Body == 1) {
        Legs++;
        //cout << Legs << endl;
    }
}

void ApplyRoll(int Roll, int &Body, int &Head, int &Antennae, int &Legs, int &Eyes, int &Lips) {
// add the corresponding Cootie piece from the roll
    if(Roll == 1) {
        AddBody(Body);
        //cout << "ADD BODY" << endl;
    }
    else if(Roll == 2) {
        AddHead(Body, Head);
        //cout << "ADD HEAD" << endl;
    }
    else if(Roll == 3) {
        AddAntennae(Body, Head, Antennae);
        //cout << "ADD ANTENNAE" << endl;
    }
    else if(Roll == 4) {
        AddEyes(Body, Head, Eyes);
        //cout << "ADD EYES" << endl;
    }
    else if(Roll == 5) {
        AddLips(Body, Head, Lips);
        //cout << "ADD LIPS" << endl;
    }
    else if(Roll == 6) {
        AddLegs(Body, Head, Legs);
        //cout << "ADD LEGS" << endl;
    }
}

string PrintCootie(int &Body, int &Head, int &Antennae, int &Legs, int &Lips, int &Eyes) {
// pieces in the Cootie so far  
    cout << "Cootie has ";

    if(Body == 1) {
        cout << "body ";
    }
    if(Head == 1) {
        cout << "head ";
    }
    if(Antennae == 1) {
        cout << "antennae ";
    }
    if(Legs <= 6 && Legs > 0) {
        cout << "legs(" << Legs << ") ";
    }
    if(Lips == 1) {
        cout << "lips ";
    }
    if(Eyes == 1) {
        cout << "eyes";
    }
    
    cout << "." << endl; 
}

bool CootieComplete(int &Body, int &Head, int &Antennae, int &Legs, int &Lips, int &Eyes) {
// return 1=finished, 0=incomplete
    if (Body == 1 && Head == 1 && Antennae == 1 && Legs == 6 && Lips == 1 && Eyes == 1) {
        return 1;
    }
    else {
        return 0;
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.