prev up next   top/contents search

comp.lang.c FAQ list · Question 7.3

Q: But the man page for strcat says that it takes two char *'s as arguments. How am I supposed to know to allocate things?


A: In general, when using pointers you always have to consider memory allocation, if only to make sure that the compiler is doing it for you. If a library function's documentation does not explicitly mention allocation, it is usually the caller's problem.

The Synopsis section at the top of a Unix-style man page or in the ANSI C standard can be misleading. The code fragments presented there are closer to the function definitions used by an implementor than the invocations used by the caller. In particular, many functions which accept pointers (e.g. to structures or strings) are usually called with a pointer to some object (a structure, or an array--see questions 6.3 and 6.4) which the caller has allocated. Other common examples are time (see question 13.12) and stat.


prev up next   contents search
about this FAQ list   about eskimo   search   feedback   copyright

Hosted by Eskimo North