top/contents search

13. Library Functions

13.1 How can I convert numbers to strings (the opposite of atoi)? Is there an itoa function?

13.2 Why does strncpy not always place a '\0' terminator in the destination string?

13.3 Does C have anything like the ``substr'' (extract substring) routine present in other languages?

13.4 How do I convert a string to all upper or lower case?

13.5 Why do some versions of toupper act strangely if given an upper-case letter?
Why does some code call islower before toupper?

13.6 How can I split up a string into whitespace-separated fields?
How can I duplicate the process by which main() is handed argc and argv?

13.7 I need some code to do regular expression and wildcard matching.

13.8 I'm trying to sort an array of strings with qsort, using strcmp as the comparison function, but it's not working.

13.9 Now I'm trying to sort an array of structures with qsort. My comparison function takes pointers to structures, but the compiler complains that the function is of the wrong type for qsort. How can I cast the function pointer to shut off the warning?

13.10 How can I sort a linked list?

13.11 How can I sort more data than will fit in memory?

13.12 How can I get the current date or time of day in a C program?

13.13 I know that the library function localtime will convert a time_t into a broken-down struct tm, and that ctime will convert a time_t to a printable string. How can I perform the inverse operations of converting a struct tm or a string into a time_t?

13.14 How can I add N days to a date? How can I find the difference between two dates?

13.14b Did C have any Year 2000 problems?

13.15 I need a random number generator.

13.16 How can I get random integers in a certain range?

13.17 Each time I run my program, I get the same sequence of numbers back from rand().

13.18 I need a random true/false value, so I'm just taking rand() % 2, but it's alternating 0, 1, 0, 1, 0...

13.19 How can I return a sequence of random numbers which don't repeat at all?

13.19b How can I generate floating-point random numbers?

13.20 How can I generate random numbers with a normal or Gaussian distribution?

13.21 I'm porting this program, and it calls a routine drand48, which my library doesn't have. What is it?

13.22 Is exit(status) truly equivalent to returning the same status from main?

13.23 What's the difference between memcpy and memmove?

13.24 I'm trying to port this old program. Why do I get ``undefined external'' errors for some library functions?

13.25 I keep getting errors due to library functions being undefined, but I'm #including all the right header files.

13.26 I'm still getting errors due to library functions being undefined, even though I'm explicitly requesting the right libraries while linking.

13.27 Why is my simple program, which hardly does more than print ``Hello, world!'' in a window, compiling to such a huge executable (several hundred K)? Should I #include fewer header files?

13.28 What does it mean when the linker says that _end is undefined?

13.29 My compiler is complaining that printf is undefined! How can this be? It's the world's most popular C function...


contents search
about this FAQ list   about eskimo   search   feedback   copyright

Hosted by Eskimo North