I have a working program here with two recursive functions. The assignment here is:
a. Write a recursive function writeLine() that writes a character repeatedly to form a line of n characters. For example, writeLine('*',5) should produce the line *****.
b. Write a recursive function writeBlock() that uses the method writeLine() to write m lines of n characters each. For example, writeBlock('*',5,3) should produce the following output:
*****
*****
*****
Here is the working solution. However there is an error on my part. It compiled and everything but when I choose the number of lines to return in the main function, it only returns 0's until the stack overflows and the program crashes. What did I do wrong ?
well because if i make both of the recursive functions type 'int', then they have to return a value right? idk how to write a recursive function that isnt a void. if i set the variable wRvar = writeLine(xchar, numInt) then when i use it in the 'void' recursive function writeBlock() i dont know what type wRvar should be.
Your assignment declares writeBlock should take 3 args writeBlock('*',5,3), neither function needs to return anything. You already ask the user for number of characters to output per line and how many lines. You need a call to writeLine within writeBlock for this to work.
Just a side note, this: while (answer == 'Y' || 'y'); will not do what you expect it to. It tests answer for 'Y', and then tests 'y' by itself (which will always evaluate to true). It's necessary to restate what object you're comparing. while(answer == 'Y' || answer == 'y') will work properly.
An alternative is including <cctype> and using tolower(char) or toupper(char) to lose case sensitivity.
The unresolved external is because you added constant's to the writeBlock definition but not declaration and the call to writeBlock has too few args. As Creative said the references aren't necessary neither are the const.