determining size of struct

This is a discussion on determining size of struct within the C Programming forums, part of the General Programming Boards category; Hello, when determining sizeof structs, does the sizeof() interprets char *string[10] as size of one pointer or size of 10 ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    61

    determining size of struct

    Hello,

    when determining sizeof structs, does the sizeof() interprets char *string[10] as size of one pointer or size of 10 characters?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,990
    It returns the size of 10 pointers to char.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    61
    so lets say natural alignment of pointer is 4, total size of the char *string[10] = 40?

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,990
    Yes.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    61
    thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting from C to C++
    By Taka in forum C++ Programming
    Replies: 5
    Last Post: 04-08-2009, 02:16 AM
  2. struct pointer
    By t014y in forum C Programming
    Replies: 5
    Last Post: 01-26-2009, 02:50 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Replies: 11
    Last Post: 03-25-2003, 04:13 PM
  5. Determining Data Size For Network Send/Rec :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 6
    Last Post: 05-07-2002, 09:01 PM

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