Thread: <tchar.h> vs. <winnt.h>

  1. #1
    C/C++ homeyg's Avatar
    Join Date
    Nov 2004
    Location
    Louisiana, USA
    Posts
    209

    <tchar.h> vs. <winnt.h>

    I'm on chapter 2 of Petzold's book and I'm kind of confused about something. Is the TCHAR declared in <tchar.h> related to, in any way, the TCHAR declared in <winnt.h>?

    I'm assuming that they aren't and that you need <tchar.h> just to use functions like _stprintf() and _vstprintf() to use with regular console programs, right?

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    I'm on chapter 2 of Petzold's book and I'm kind of confused about something. Is the TCHAR declared in <tchar.h> related to, in any way, the TCHAR declared in <winnt.h>?
    The TCHAR type is defined in one or the other depending on which one is included first. You really don't need to know the details, other than that a TCHAR is an ordinary char or a unicode character (when both _UNICODE and UNICODE are defined).
    I'm assuming that they aren't and that you need <tchar.h> just to use functions like _stprintf() and _vstprintf() to use with regular console programs, right?
    These functions (strictly macros) are defined in <tchar.h>, so yes you need to include that file to use them.

Popular pages Recent additions subscribe to a feed