LibRCG
3.1.1
|
Implementation of some utility functions. More...
Go to the source code of this file.
Functions | |
int | rgets (char **str) |
Reads a line from the stdin. More... | |
int | rgetsEOF (char **str) |
Reads a text from the stdin. More... | |
int | rngets (char *str, int dim) |
Reads a line from the stdin. More... | |
int | getRandom (int min, int max) |
Generates a random number in a given interval. More... | |
int | mergeSort (void *vals[], int begin, int end, int(*comp)(void *, void *)) |
Orders an array into ascending order, based on a given comparison function. More... | |
Implementation of some utility functions.
Provides functions to read text from de stdin, to generate random numbers, and to sort arrays.
Definition in file util.h.
int getRandom | ( | int | min, |
int | max | ||
) |
Generates a random number in a given interval.
max
must be greater than min
, otherwise the function will return 0.min | minimum allowed value |
max | maximum allowed value |
int mergeSort | ( | void * | vals[], |
int | begin, | ||
int | end, | ||
int(*)(void *, void *) | comp | ||
) |
Orders an array into ascending order, based on a given comparison function.
Uses the algorithm merge sort.
vals | array of pointer to the elements to sort |
begin | starting position |
end | ending position |
comp | comparison function |
int rgets | ( | char ** | str | ) |
Reads a line from the stdin.
Reads all characters until a \n
.
str | pointer where a string containing the line read shall be put |
str
is invalidint rgetsEOF | ( | char ** | str | ) |
Reads a text from the stdin.
Reads all characters until an EndOfFile.
str | pointer where a string containing the text read shall be put |
str
is invalidint rngets | ( | char * | str, |
int | dim | ||
) |
Reads a line from the stdin.
Reads all characters until a \n
. The line shall not exceed the size dim-2 (the additional characters will be lost).
str | pointer where the text read shall be put |
dim | maximum size for the line to be read (the line shall not exceed the size dim-2) |
LibRCG © 2004-2015 Rui Carlos Gonçalves