Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!columbia!rutgers!ames!ucbcad!ucbvax!SRI.COM!STEINBERGER From: STEINBERGER@SRI.COM (Richard Steinberger) Newsgroups: comp.os.vms Subject: C question Message-ID: <12323814505.10.STEINBERGER@SRI.Com> Date: Tue, 4-Aug-87 10:54:57 EDT Article-I.D.: SRI.12323814505.10.STEINBERGER Posted: Tue Aug 4 10:54:57 1987 Date-Received: Thu, 6-Aug-87 02:21:33 EDT Sender: daemon@ucbvax.BERKELEY.EDU Distribution: world Organization: The ARPA Internet Lines: 41 I'm a fairly new C language user and I apologize in advance if this question has an obvious answer. It concerns the use of CALLOC, the memory allocating function. On page 9-3 of the VAX C Run Time Reference Library the syntax is described as: #include stdlib void *calloc(size_t number, size_t size); My understanding of ANSI C is that a new use for the VOID keyword is that it can refer to a function that can return a pointer to any data type and thus obviate the need for casting. I tried using the CALLOC function (with the #include stdlib, which the compiler couldn't find). The compiler wouldn't accept this form, declaring something about void refering to functions that return no arguments (a more "standard" usage for void). I looked on page D-5 of the same manual where it describes the syntax as: char *calloc(unsigned number, unsigned size); I was able to get this to work when I declare and use them as follows: int number, *integer_ptr; char *calloc(); . . integer_ptr = (int *) calloc(number, sizeof(int)); . . My questions are: Is there an error on page 9-3 (as it conflicts with page D-5), or am I just not understanding how to use the CALLOC with the void keyword? Where, if anywhere, are the size_t data types defined? I used: #include stdlib and the compiler was unable to find it. What's wrong here? In short, what's the best way to use the CALLOC function? Thanks to all who reply. -Ric Steinberger steinberger@kl.sri.com -------