But the man page for strcat says that it takes two char *'s as arguments. How am I supposed to know to allocate things?
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 the address of some object (a structure, or an array--see questions 6.3 and 6.4). Other common examples are time (see question 13.12) and stat.
Read sequentially: prev next up top
This page by Steve Summit // Copyright 1995 // mail feedback