Error: Function 'mirror' should have a prototype

The program wants to:
Transform a number in base q (q<10) and write it in a folder, using recursivity (calling the same function in the function itself)
What my program does:
First function gives the number in base q, but from left to right(mirrored).
Second function makes the number in the correct order (from left to right).
Both functions work on the principle of recursivity.
The program is:
#include <fstream.h>
ifstream f ("bazaq.in");
ofstream g ("bazaq.out");
int n,q;
int base (int n, int nr)
{
if(!n)
return mirror(nr,0);
else{
nr=nr+n%q;
nr/=q;
return base(n,nr);
}
}
int mirror (int x, int y)
{
if(!x)
return y;
else{
y=y*10+x%10;
x/=10;
return mirror(x,y);
}
}
void main ()
{
f>>n>>q;
g<<baza(n,0);
}

My problem is:
Error: Function 'mirror' should have a prototype
How can i fix it??

I use Borland C++ v 3.1

Comments

  • First of all, wrap all of your code in code tags, it will preserve the indentation so it doesn't look like crap. Now, the problem with your program is that you made a call to a function (mirror) that you defined [italic]later[/italic] on in the code. Either cut and paste the mirror() function above the main() function, or just type this before the main() function:

    [code]
    int mirror(int x, int y);
    [/code]
  • : First of all, wrap all of your code in code tags, it will preserve
    : the indentation so it doesn't look like crap. Now, the problem with
    : your program is that you made a call to a function (mirror) that you
    : defined [italic]later[/italic] on in the code. Either cut and paste
    : the mirror() function above the main() function, or just type this
    : before the main() function:
    :
    : [code]:
    : int mirror(int x, int y);
    : [/code]:
    :
    Thanks for solving my problem.
    What is a code tag?
  • [leftbr]code[rightbr]

    /* code goes here */

    [leftbr]/code[rightbr]
  • may be your header file is missing.[size=5][color=Purple][/color][/size]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories