The function strstr() returns a pointer to the first occurrence of x in a string.
It is also know as searching for a sub-string in a string.
Usage:
char * strstr ( const char *, const char * );
char * strstr ( char * str1, const char * str2 );
Return Value
A pointer to the first occurrence in str1 of any of the entire sequence of characters specified in str2. If nothing is found a null pointer is returned if the sequence is not present in str1.
More »
Posted in C Reference string.h Functions |
Usage of clock():
clock_t clock ( void );
Parameters:
None.
Return Value:
The number of clock ticks elapsed since the program start. If the function fails then it will return a value of -1. The clock_t type is defined in ctime.h.
Explanation:
The function returns the number of clock ticks elapsed since the start of the program. More »
Posted in C Reference time.h Functions |
Usage of difftime():
double difftime ( time_t time2, time_t time1 );
Parameters:
Time1 and time2 are both time_t objects.
Return Value:
The difference in seconds between time2-time1 will be returned as a floating point double.
Explanation:
Calculates the difference in seconds between time1 and time2. More »
Posted in C Reference time.h Functions |
The null pointer macro (NULL) is generally used to signify that a pointer does not point to an object.
Posted in C Reference time.h Functions |
Usage of mktime():
time_t mktime ( struct tm * ptr_time );
Parameters:
The pointer ptr_time points to a tm structure that contains a calendar time, which in turn is broken down into its components.
Return Value:
A time_t value corresponding to the calendar time passed as argument.
If an error occurs then the function mktime() returns a -1 value. More »
Posted in C Reference time.h Functions |
Usage of time():
time_t time ( time_t * ptr_time );
Parameters:
ptr_time is a pointer to an object of type time_t. In this object the time value is stored.
It is also allowed to fill in a null pointer, but the a time_t object is still returned by the function time().
Return Value:
The current calendar time as a time_t object. More »
Posted in C Reference time.h Functions |
The function mlen() of the library stdlib.h is used to get the length of a multi-byte character.
Usage of mblen():
int mblen ( const char * pmb, size_t max );
The pmb (pointer multibyte character) pointer is pointing to the multi-byte value where you want to know the size of. It will only examine at most max bytes.
Parameters:
More »
Posted in C Reference stdlib.h Functions |
The function mbtowc(), that is part of the stdlib.h library, is used to convert a multi-byte character to wide character.
Usage of mbtowc():
int mbtowc ( wchar_t * pwc, const char * pmb, size_t max );
The multibyte character pointed by pmb (pointer multibyte character) is converted to a wide character which is stored at the location that is pointed by pwc (pointer wide character). The length in bytes of the multiby character is returned. More »
Posted in C Reference stdlib.h Functions |
The function qsort() of the stdlib.h is used to sort the elements of an array.
Usage of qsort():
void qsort ( void * base, size_t num, size_t size, int ( * comparator ) ( const void *, const void * ) );
The function qsort() sorts the num element of the array pointed by base. Every element has a size of size bytes long. The qsort function will use the comparator function to determine the order of the elements.
The function will not return a value. The content is modified in the newly sorted order.
Parameters:
More »
Posted in C Reference stdlib.h Functions |
The function bsearch() of the stdlib.h is used to do a binary search in an array.
Usage of bsearch():
void * bsearch ( const void * key, const void * base, size_t num, size_t size, int ( * comparator ) ( const void *, const void * ) );
It is searching for a given key in the array that is pointed to by base. Base is formed by the number of elements (num). Each element has a size of size bytes. The function will return a void* pointer to the first element that is matching the search key. The function compares each element to the key by calling the comparator. More »
Posted in C Reference stdlib.h Functions |