The Open Source Swiss Army Knife

/code/c/ISO_c_basics/
/code/c/ISO_c_basics/ + sub-categories
http://www.sirfsup.com/
web directory content
    
      

Not logged in
Chat Register Login
return to:  http:/www.sirfsup.com      /code   /c   /ISO_c_basics 
Permalink: data_tipz.htm
Title: microsoft and unix specific and ISO c data types (int, size_t...
article options : please login   |  print view

C data types

general C data types

    1. unsigned int: same as 'unsigned char', holds then +-127
    2. short:
    3. double:
    4. float
    5. : 64 bit
    6. volatile: used to specify that a variable can be modified outside of main.
    following is from sizeof.c this directory:
    A char      is 1 bytes
    An int      is 4 bytes
    A short     is 2 bytes
    A long      is 4 bytes
    An unsigned char  is 1 bytes
    An unsigned int   is 4 bytes
    An unsigned short is 2 bytes
    An unsigned long  is 4 bytes
    A float     is 4 bytes
    A double    is 8 bytes
    

microsoft-specific data types

strings
  1. bstr: a length-prefixed string.
  2. _bstr_t
  3. lpctstr
  4. lpstr
  5. _T (a string precessor, which casts the string)
  6. lpcwstr
  7. lpwstr: in 32-bit type libraries Unicode strings can be defined with the LPWSTR data type.
  8. lpstr: indicates a zero-terminated string
  9. olechar

BSTR

A length-prefixed string used by Automation data manipulation functions. It has been described both as typedef OLECHAR *BSTR; and typedef LPWSTR. It is just a LPWSTR with the string length prefixed onto the string, taking up the first ULONG bytes.

BSTRs are wide, double-byte (Unicode) strings on 32-bit Windows

You create a string with SysAllocString.

And you release it with SysFreeString.

to get the length of a BSTR pass it to SysStringLen.

you changes the BSTR with SysReAllocString().

There are no functions to manipulate a sub-string within a BSTR...

compare javascript:

subst('Quiet lulls the peaceful mind', 'l', 'XX')

Results:Quiet XXuXXXXs the peacefuXX mind

subst('Quiet lulls the peaceful mind', 'l', 'll')

Results:Quiet llulllls the peacefull mind

substring( aStartIndex, anEndIndex)

Returns the characters found between the start and end indices, e.g., "Hello World".substring(0,1) returns "H". "Hello World".substring(4,10) returns "o Worl".

string1 + string2

Creates a new string which appends string1 with string2, e.g., "Hello "+"World" returns "Hello World"

compare VB:

Convert the code to a MFC CString or an STL basic_string<> and then use a SysReAllocString().

bstr_t

_bstr_t( char* s2 )

Constructs a _bstr_t object by calling SysAllocString to create a new BSTR object and encapsulate it. This constructor first performs a multibyte to Unicode conversion.

lpctstr

An LPCWSTR if UNICODE is defined, an LPCSTR otherwise. In other words, it is a pointer to a constant generic string.

lpcwstr

a constant for a lpcwstr.

lpstr

Pointer to a constant null-terminated string of 8-bit Windows (ANSI) characters.

lpwstr

Pointer to a constant null-terminated string of 16-bit Unicode characters.

VARIANT

A varaint is a union.

see the union how-to file in the howto/c/unions.htm directory . Books always document this data type. A Variant is based on the union type. The CComVariant type is an encapsulation of the three necessary steps in creating and using a VARIANT type.

atl data types

CComBSTR

CComBSTR();
CComBSTR(int nSize);
CComBSTR(int nSize, LPCOLESTR sz);
CComBSTR(LPCOLESTR psrc);
CComBSTR(const CComBSTR& src);
CComBSTR(REFGUID src); /*converts a GUID to a BSTR */

SAFEARRAY


Leave a Reply
Your Name:     anonymous
Your Email:
Website:  
Comments:

The author will be notified of your reply.
return to top