Page 1 of 1

Why is this so simple code compiled error?

Posted: Fri Feb 17, 2006 6:17 am
by ImLazy

Code: Select all

#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int a = -1;
    int b = abs(a);
    cout << b << endl;
    return 0;
}

Re: Why is this so simple code compiled error?

Posted: Fri Feb 17, 2006 6:54 am
by sumankar
ImLazy wrote:

Code: Select all

#include <cmath>
should've been

Code: Select all

#include <cstdlib>
man for abs.

Re: Why is this so simple code compiled error?

Posted: Fri Feb 17, 2006 7:12 am
by misof
sumankar wrote:man for abs.
And in case you only have windoze and no man pages, google for "man abs" ;)

Posted: Fri Feb 17, 2006 8:42 am
by ImLazy
I don't quite understande what is man page.
At least now I know I should include <cstdlib> instead of <cmath>. Thank you.

Posted: Fri Feb 17, 2006 8:47 am
by misof
ImLazy wrote:I don't quite understande what is man page.
At least now I know I should include <cstdlib> instead of <cmath>. Thank you.
"man" is short for manual, this is the standard *NIX way of accessing simple text-based documentation to almost everything. The most common are man pages for programs, but there are also man pages for C functions, system calls, and many other things.