Hey ppl,
Im trying to solve some problems for topcoder website for practice purposes. But the compiler shows the following error for the codes i've been compiling. I have no problems compiling these codes with Borland C++. I've posted the errors and code below.
Errors:
Your code did not compile:
errors linking:
SquareDigits-stub.o(.text+0x240): In function `main':
: multiple definition of `main'
SquareDigits.o(.text+0x174): first defined here
/usr/bin/ld: Warning: size of symbol `main' changed from 69 in SquareDigits.o to 532 in SquareDigits-stub.o
collect2: ld returned 1 exit status
#include<iostream>
using namespace std;
class SquareDigits
{
public:
int smallestResult (int);
};
int SquareDigits :: smallestResult (int n)
{
int digitCount,quotient,digits[5];
cout << "Please enter the no of digits in the no entered :" << endl;
cin >> digitCount;
quotient = n;
cout << "The digits of the number entered are listed below :" <<endl;
for (int i=0; i<digitCount; i++)
{
digits[i] = quotient%10;
quotient = n/10;
cout << digits[i] << endl;
}
return 0;
}
int main()
{
SquareDigits s;
int sample;
cout << "Enter a no :" << endl;
cin >> sample;
s.smallestResult(sample);
return 0;
}
PS: This code is not complete. This code just extracts digits from a given no and saves it in an array for now.