create new tag
, view all tags
from "Teach Yourself C Programming in 21 Days"; Aitken and Jones, 1995:

C keyword used to signify either a function that does not return anything or that a pointer being used is considered generic or able to point to any data type.

Maybe that relieves some of the confusion I had when I first posted some of the following:

Then another quote from the same book that gives me a hint: "You've seen the void keyword used to specify that a function either doesn't take arguments or doesn't return a value." I guess that almost clears up my first question below (but not quite, is <function_name> (void) the same as <function_name> (), or is there some difference?).

I thought I understood what "void" meant in C (a void function does not return a value), but now I've seen some uses of void which I don't understand, like:

  • void getlines(void); — I understand the first void, but is the second any different than getlines()?? (from page 6 of Data Structures and Programs by Van Wyk) — is the second void a generic pointer???
  • a different use, I think (from page 132 of the same book) — OK, I guess that is the second case, figure looks like a generic pointer:

typedef void figure;

typedef struct circle {
   figure *next;
   int kind;
   point center;
   double radius;
} circle;

typedef struct rectangle {
   figure *next;
   int kind;
   point sw, ne;
} rectangle;

  • from [[http://www.cuj.com/articles/1998/9804/9804a/sidebar.htm?topic=articles][]]:

void * operator new(size_t, void *whereToPutObject)
{ return whereToPutObject; }

This particular version of operator new — the one taking an extra void* argument specifying what pointer the function should return — is so commonly useful that it's in the Standard C++ library (declared in the header ) and it has a name, "placement new." The name indicates its purpose: to allow programmers to specify where in memory an object should be created (where it should be placed).





  • () RandyKramer - 23 Apr 2003
  • If you edit this page: add your name here; move this to the next line; and if you've used a comment marker (your initials in parenthesis), include it before your WikiName.

Page Ratings

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2003-04-23 - RandyKramer
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by PerlCopyright 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding WikiLearn? WebBottomBar">Send feedback
See TWiki's New Look