Thread: help! size_t, unigned int and puts()

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2012
    Location
    Some rock floating in space...
    Posts
    32

    Exclamation

    Quote Originally Posted by whiteflags View Post
    size_t is required to be able to represent, in bytes, the size of an object of any type that can be examined by the sizeof() operator. So if you needed to represent say the length of a string, it is a rather logical choice, given that there are environmental, minimal limits on the size of an array (and other things) in standard C. The minimum limit of the size of an object, that means that the compiler must translate source containing an object of this size, is 2^16, in C99.

    unsigned int is just an unsigned integer (read positive values only) type that can support different ranges on different platforms. It is a general purpose integer type.



    I don't think you're wrong, that just doesn't matter. You're pointing out an implementation detail.
    According to WG14/N1256 Committee Draft — Septermber 7, 2007 ISO/IEC 9899:TC3

    The return value of sizeof is "implementation-defined" and is said to be an unsigned value. And it says that size_t IS defined in stddef.h and/or other headers...

    4 The value of the result is implementation-defined, and its type (an unsigned integer type)
    is size_t, defined in <stddef.h> (and other headers).
    You can read the full text at the following address...

    http://www.open-std.org/jtc1/sc22/WG...docs/n1256.pdf

    **EDIT**

    Sorry... had to fully understand my own post...
    Last edited by twiki; 11-25-2012 at 07:27 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. puts/fputs
    By joybanerjee39 in forum C Programming
    Replies: 5
    Last Post: 10-25-2011, 02:49 PM
  2. puts array
    By meher81 in forum C Programming
    Replies: 21
    Last Post: 03-27-2010, 07:11 AM
  3. gets and puts does'nt work!!
    By behzad_shabani in forum C Programming
    Replies: 46
    Last Post: 06-16-2008, 10:18 AM
  4. puts( );
    By xddxogm3 in forum C Programming
    Replies: 9
    Last Post: 03-28-2005, 12:42 PM
  5. putchar vs puts
    By sballew in forum C Programming
    Replies: 7
    Last Post: 09-20-2001, 02:02 PM

Tags for this Thread