I am having trouble passing two variable types into my printPattern function. I need to pass rows and characterSelect from my getInput function into my printPattern function. I keep getting a "printPatte rn function does not take 0 arguments" error. I'm pretty sure this means nothing is being passed to my printPattern function, but I can't figure out why. Does anyone have any suggestions? Here's my code:
Thanks for help any may have. For me, understanding functions has been one of the hardest things to master in C++ so far.
Code:
// 11/26/06
// Program allows user to select number and type of pattern to be printed to screen
#include <iostream>
using namespace std;
// Function prototypes
void getInput(int&, char&);
void printError(int&, char&);
int printPattern(int, char);
int main()
{
int numRows = 0;
char typeChar = 0;
getInput(numRows, typeChar);
printPattern(int& rows, char& characterSelect);
return 0;
}
//************************************************************************
// Definition of getInput which obtains user info on how to build pattern*
//************************************************************************
void getInput(int& rows, char& characterSelect)
{
cout << "How many rows do you want in the pattern (even numbers only: 2-14)? ";
cin >> rows;
cout << "What character do you want the pattern made of (select from: * + # or $)? ";
cin >> characterSelect;
printError(rows, characterSelect);
}
//************************************************************************
// Definition of printError which determines if user has entered *
// acceptable input. *
//************************************************************************
void printError(int& rows, char& characterSelect)
{
if ((rows < 2) || (rows > 14) || (rows%2 != 0))
{
cout << "\nInvalid number of rows. Please retry.\n";
cout << "\n";
getInput(rows, characterSelect);
}
else if ((characterSelect != '*') && (characterSelect != '+') && (characterSelect != '#') && (characterSelect != '$'))
{
cout << "\nInvalid character. Please retry using one of the four characters given.\n";
cout << "\n";
getInput(rows, characterSelect);
}
}
//************************************************************************
// Definition of printPattern displays pattern based on user entered data*
//************************************************************************
int printPatter(int& rows, char& characterSelect)
{
int halfValue = rows / 2;
return 0;
}
Comment