quick question about sizeof operator

This is a discussion on quick question about sizeof operator within the C++ Programming forums, part of the General Programming Boards category; Is sizeof similar to a function in that it is 'called' each time I place it in my code (meaning ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    552

    quick question about sizeof operator

    Is sizeof similar to a function in that it is 'called' each time I place it in my code (meaning will any calculations take place at every sizeof), or will some sort of constant be placed in the code instead?

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    Because sizeof is not a function but instead a compile time operator the answer to your question is that the compiler will replace the sizeof with a constant.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie question about 'sizeof' and arrays
    By Sharke in forum C Programming
    Replies: 27
    Last Post: 12-09-2009, 05:30 AM
  2. Quick Sizeof Question
    By PetrolMan in forum C++ Programming
    Replies: 4
    Last Post: 03-30-2009, 12:30 AM
  3. malloc and sizeof question
    By cus in forum C Programming
    Replies: 4
    Last Post: 01-03-2009, 11:23 AM
  4. Quick question about types...
    By Elysia in forum C++ Programming
    Replies: 32
    Last Post: 12-07-2008, 04:39 AM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21