Implicit declaration of function 'abs' is invalid in C99


#1

To avoid this warning, you should explicitly declare the function abs for usage.

[code]#include <stdio.h>

int abs(int someInteger);

int main(int argc, const char * argv[])
{

printf(“The abs val of -5 is %d\n”, abs(5));

return 0;

}
[/code]


#2

try:

#include <stdlib.h>

Mitch


#3

Or you know, do what the book does and include:

You need that one in order for abs() to work.

From the book: “Both functions are declared in stdlib.h:”