I'm just looking for a hint in the right direction if someone could help me please. The first part works good, but i can't the the call by reference to reverse the digits for me. It outputs a 0 or it outputs the numbers in the same order that i input them.

Code:

// reversedigits.cpp
// written by
// cis
#include <iostream>
#include <iomanip>
using namespace std;
int revdigits ( int ); // call by value
void revdigits1 ( int, int& );// call by reference
int width ( int ) ;
void width1 ( int, int& );
int main()
{
int number = 0,
r = 0;
cout << "Enter a number between 1 and 9999: " << fixed;
cin >> number;
cout << "The number with its digits reversed is: " << setw ( width ( number ) ) << revdigits ( number ) << endl;
void revdigits1 ( int n, int r );
cout << "The number with its digits reversed is: " ;
void width1 ( int n,int r );
cout << r << endl;
return 0;
}
int revdigits ( int n )
{
int reverse = 0,
divisor = 1000,
multiplier = 1;
while ( n > 10 )
{
if ( n >= divisor )
{
reverse += n / divisor * multiplier;
n %= divisor;
divisor /= 10;
multiplier *= 10;
}
else
divisor /= 10;
}
reverse += n * multiplier;
return reverse;
}
void revdigits1 ( int n, int &r )
{
int reverse = 0,
divisor = 1000,
multiplier = 1;
while ( n > 10 )
{
if ( n >= divisor )
{
reverse += n / divisor * multiplier;
n %= divisor;
divisor /= 10;
multiplier *= 10;
}
else
divisor /= 10;
}
reverse += n * multiplier;
r = reverse;
}
int width ( int n )
{
if ( n / 1000 )
return 4;
else if ( n / 100 )
return 3;
else if ( n / 10 )
return 2;
else
return 1;
}
void width1 ( int n, int &r )
{
if ( n / 1000 )
r = 4;
else if ( n / 100 )
r = 3;
else if ( n / 10 )
r = 2;
else
r = 1;
}