Thread: size of <char>

  1. #1
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195

    size of <char>

    I have a piece fo code that I need to modify to return the number of bytes in a smart array of type <char>. Anyone know how to do this? I don't use smart types (I think they are yucky), but I have to fix someone elses code on this one.

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by abachler View Post
    I have a piece fo code that I need to modify to return the number of bytes in a smart array of type <char>. Anyone know how to do this? I don't use smart types (I think they are yucky), but I have to fix someone elses code on this one.
    What is a "smart array?"

  3. #3
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Quote Originally Posted by brewbuck View Post
    What is a "smart array?"
    its that STL crapola like <char> Foo instead of char Foo[];

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by abachler View Post
    its that STL crapola like <char> Foo instead of char Foo[];
    You mean a vector? The size of a vector of char, in bytes, is simply array.size()

  5. #5
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    thx

  6. #6
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Note that the only definite guarantee that C and C++ give about sizes of types is that sizeof(char) == 1. That's because other types are measured in terms of char.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #7
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I see you using a lot of windows-esque notation in some of your other code. Are you working with chars or TCHARs?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trouble with DMA Segmentation Faults
    By firestorm717 in forum C Programming
    Replies: 2
    Last Post: 05-07-2006, 09:20 PM
  2. Pointer Size Relative To Integers?
    By SMurf in forum C Programming
    Replies: 1
    Last Post: 04-18-2006, 06:58 AM
  3. Invalid conversion from 'void*' to 'BYTE' help
    By bikr692002 in forum C++ Programming
    Replies: 9
    Last Post: 02-22-2006, 11:27 AM
  4. An exercise in optimization
    By Prelude in forum Contests Board
    Replies: 10
    Last Post: 04-29-2005, 03:06 PM