This shows you the differences between two versions of the page.
— |
c:stdlib.h:abs [2024/02/16 01:04] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{keywords>wiki library source code example reference}} | ||
+ | ====== abs ====== | ||
+ | |||
+ | <code c> | ||
+ | #include <stdlib.h> | ||
+ | int abs(int i); | ||
+ | </code> | ||
+ | |||
+ | computes the absolute value of the integer i | ||
+ | |||
+ | ===== C Sourcecode Example ===== | ||
+ | <code c> | ||
+ | #include <stdio.h> /* including standard library */ | ||
+ | //#include <windows.h> /* uncomment this for Windows */ | ||
+ | /* for printf */ | ||
+ | #include <stdlib.h> | ||
+ | |||
+ | int main( void ) | ||
+ | { | ||
+ | int i = -42; | ||
+ | printf("abs from i = %d\n", abs(i)); | ||
+ | return 0; | ||
+ | } | ||
+ | |||
+ | </code> | ||
+ | |||
+ | ==== output with abort: ==== | ||
+ | user@host:~/code-reference.com# ./abs | ||
+ | abs from i = 42 | ||
+ | |||