- Strona pocz±tkowa
- 292. Macomber Debbie Synowie PóśÂ‚nocy 01 Narzeczona dla brata
- Krahn Betina Ukryty pśÂ‚omieśÂ„ (Skaza)
- Gombrowicz Bakakaj
- Dr Pierre Dukan Nie potrafić™ schudnć…ć‡(caśÂ‚a ksić…śźka)
- 01 Homeland
- Bailey Bradford Southwestern Shifters 05 Resilience
- Dan Abnett Eisenhorn 01 Xenos
- Jack Mcdeviit Deepsix
- Angel Bd01 Nancy Holder Stadt der Träume
- Arthur C. Clarke Miasto I Gwiazdy
- zanotowane.pl
- doc.pisz.pl
- pdf.pisz.pl
- fotoexpress.htw.pl
[ Pobierz całość w formacie PDF ]
whitespace). scanf() uses the pointers &num, s1, and s2 to store what it finds into the
local variables.
ctype.h
ctype.h includes macros for doing simple tests and operations on characters
isalpha(ch) // ch is an upper or lower case letter
islower(ch), isupper(ch) // same as above, but upper/lower specific
isspace(ch) // ch is a whitepace character such as tab, space, newline, etc.
isdigit(ch) // digit such as '0'..'9'
toupper(ch), tolower(ch) // Return the lower or upper case version of a
alphabetic character, otherwise pass it through unchanged.
44
string.h
None of these string routines allocate memory or check that the passed in memory is the
right size. The caller is responsible for making sure there is "enough" memory for the
operation. The type size_t is an unsigned integer wide enough for the computer's
address space -- most likely an unsigned long.
size_t strlen(const char* string);
Return the number of chars in a C string. EG strlen("abc")==3
char* strcpy(char* dest, const char* source);
Copy the characters from the source string to the destination string.
size_t strlcpy(char* dest, const char* source,
size_t dest_size);
Like strcpy(), but knows the size of the dest. Truncates if necessary. Use this to avoid
memory errors and buffer-overflow security problems. This function is not as
standard as strcpy(), but most sytems have it. Do not use the old strncpy() function --
it is difficult to use correctly.
char *strcat(char* dest, const char* source);
Append the characters from the source string to the end of destination string. (There is
a non-standard strlcat() variant that takes the size of the dest as third argument.)
int strcmp(const char* a, const char* b);
Compare two strings and return an int which encodes their ordering. zero:a==b,
negative:ab. It is a common error to think of the result of strcmp() as
being boolean true if the strings are equal which is, unfortunately, exactly backwards.
char* strchr(const char* searchIn, char ch);
Search the given string for the first occurence of the given character. Returns a
pointer to the character, or NULL if none is found.
char* strstr(const char* searchIn, const char* searchFor);
Similar to strchr(), but searches for an entire string instead of a single character. The
search is case sensitive.
void* memcpy(void* dest, const void* source, size_t n);
Copy the given number of bytes from the source to the destination. The source and
destination must not overlap. This may be implemented in a specialized but highly
optimized way for a particular computer.
void* memmove(void* dest, const void* source, size_t n);
Similar to memcpy() but allows the areas to overlap. This probably runs slightly
slower than memcpy().
45
stdlib.h
int rand();
Returns a pseudo random integer in the range 0..RAND_MAX (limits.h) which is at
least 32767.
void srand(unsigned int seed);
The sequence of random numbers returned by rand() is initially controlled by a global
"seed" variable. srand() sets this seed which, by default, starts with the value 1. Pass
the expression time(NULL) (time.h) to set the seed to a value based on the current
time to ensure that the random sequence is different from one run to the next.
void* malloc(size_t size);
Allocate a heap block of the given size in bytes. Returns a pointer to the block or
NULL on failure. A cast may be required to store the void* pointer into a regular
typed pointer. [ed: see the Heap Allocation section above for the longer discussion of
malloc(), free(), and realloc()]
void free(void* block);
Opposite of malloc(). Returns a previous malloc block to the system for reuse
void* realloc(void* block, size_t size);
Resize an existing heap block to the new size. Takes care of copying bytes from the
old block to the new. Returns the new base address of the heap block. It is a common
error to forget to catch the return value from realloc(). Returns NULL if the resize
operation was not possible.
void exit(int status);
Halt and exit the program and pass a condition int back to the operating sytem. Pass 0
to signal normal program termination, non-zero otherwise.
void* bsearch(const void* key, const void* base, size_t len,
size_t elem_size, );
Do a binary search in an array of elements. The last argument is a function which
takes pointers to the two elements to compare. Its prototype should be:
int compare(const void* a, const void* b);, and it should return 0, -1, or 1 as strcmp()
does. Returns a pointer to a found element, or NULL otherwise. Note that strcmp()
itself cannot be used directly as a compare function for bsearch() on an array of char*
strings because strcmp() takes char* arguments and bsearch() will need a comparator
that takes pointers to the array elements -- char**.
void qsort(void* base, size_t len, size_t elem_size,
);
Sort an array of elements. Takes a function pointer just like besearch().
Revision History
11/1998 -- original major version. Based on my old C handout for CS107. Thanks to Jon
Becker for proofreading and Mike Cleron for the original inspiration.
Revised 4/2003 with many helpful typo and other suggestions from Negar Shamma and
A. P. Garcia
[ Pobierz całość w formacie PDF ]