We relaunched the TWiki.org project with an expanded TWiki charter, and we invite you to participate! The TWiki.org Code of Conduct agreement took effect on 27 Oct 2008. We ask existing twiki.org users to opt-in. You need to opt-in to participate in the Blog, Codev, Plugins and TWiki webs. -- PeterThoeny - 27 Oct 2008
You are here: TWiki> Wikilearn Web>CplVoid (23 Apr 2003, RandyKramer)
Tags:
create new tag
, view all tags
from "Teach Yourself C Programming in 21 Days"; Aitken and Jones, 1995:

void
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).

See:

Contents

Notes

Contributors

  • () 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

Topic revision: r2 - 23 Apr 2003 - 19:46:00 - RandyKramer
 
TWIKI.NET
Copyright © 1999-2008 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
See TWiki's New Look