wchar_t* declarartion


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: wchar_t* declarartion

  1. #1
    Join Date
    May 2005
    Posts
    58

    Question wchar_t* declarartion

    1) hi have never used the wchar_t data type .i am not able to follow the following declaration .

    wchar_t *sample_ok = L"sample=true";

    is it:sample_ok is pointer of type wchar_t and having value "sample=true"but why value is like "sample=true" ?

    2) what is meaning of browser_t in the function declararion?

    extern "C" int browser_script(browser_t *browser, const wchar_t *script);

  2. #2
    Join Date
    Nov 2003
    Posts
    4,118
    Quote Originally Posted by swapnil_paranja
    1) hi have never used the wchar_t data type .i am not able to follow the following declaration .

    wchar_t *sample_ok = L"sample=true";

    is it:sample_ok is pointer of type wchar_t and having value "sample=true"but why value is like "sample=true" ?
    wchar_t is a built-in type in C/C++ that represents a wide char, typically a Unicode letter. sample_ok is a pointer to this type. As you may alreayd know, pointers are treated as arrays of letters (char*, wchar_t* and so on), so sample_ok is actually a string of wide characters. The string is initialized as "sample true". The prefix L before a quoted literal string indicates that it's a wchar_t string, not a char string.

    Quote Originally Posted by swapnil_paranja
    2) what is meaning of browser_t in the function declararion?
    extern "C" int browser_script(browser_t *browser, const wchar_t *script);[/QUOTE]

    You need to look at the header file that declares this typedef. browser_t is not a built-in type so it must be a typedef of some sort. My guess is that it's a struct of that contains information about a Web broswer.
    Last edited by Danny; 05-24-2005 at 07:54 AM.
    Danny Kalev

  3. #3
    Join Date
    May 2005
    Posts
    58
    thank you!!! things are very much clear for me now.

  4. #4
    Join Date
    Dec 2003
    Posts
    3,366
    Note that its pretty standard to put a _t on user created types -- it implys class or struct. _e is enum. There are a couple of others but much less used.

  5. #5
    Join Date
    Nov 2003
    Posts
    4,118
    Not necessarily: size_t, ptrdiff_t, ssize_t (a POSIX signed size_t type) and many others are plain integers in disguise, so one can't really assume that browser_t is a struct or class. However, it seemed a resonable inference that broswer-related information would be stored in a struct that has several data members (version, vendor, OS etc.).
    Last edited by Danny; 05-24-2005 at 10:17 AM.
    Danny Kalev

  6. #6
    Join Date
    Dec 2003
    Posts
    3,366
    The stdint ones have the T too -- uint32_t -- which are also just maps to built in types.

  7. #7
    Join Date
    Nov 2003
    Posts
    4,118
    Correct. This suggests that the _t suffix can be interpreted as "this a typedef name of some sort".
    Danny Kalev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center