Standard Utility Functions Flashcards
1
Q
absolute value of int n
A
abs(n)
2
Q
absolute value of long n
A
labs(n)
3
Q
quotient and remainder of ints n,d
A
div(n,d)
4
Q
pseudo-random integer [0,RAND_MAX]
A
rand()
5
Q
set random seed to n
A
srand(n)
6
Q
terminate program execution
A
exit(status)
7
Q
allocate storage
A
malloc(size), calloc(nobj,size)
8
Q
change size of storage
A
newptr = realloc(ptr,size);
9
Q
deallocate storage
A
free(ptr);
10
Q
search array for key
A
bsearch(key,array,n,size,cmpf)
11
Q
sort array ascending order
A
qsort(array,n,size,cmpf)