CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2004
    Location
    New Delhi, India
    Posts
    640

    _tcslen header file

    i dont know but when i try to use _tcslen i get an error saying undefined function.

    which header file i should include for _tcslen iam making a win32 app.

    Regards.
    "I rather not play football than wear Nerrazzuri shirt" - Paolo Maldini
    FORZA MILAN!!!

  2. #2
    Join Date
    May 2005
    Posts
    4,954

    Re: _tcslen header file

    #include <string.h>

    Cheers

  3. #3
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: _tcslen header file

    In fact _tcslen is a macro defined in TCHAR.H.
    It expands to wcslen or strlen if _UNICODE preprocessor constant is defined or not.
    wcslen and strlen functions are indeed declared in STRING.H.
    Last edited by ovidiucucu; June 25th, 2005 at 10:54 AM.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  4. #4
    Join Date
    Sep 2004
    Location
    New Delhi, India
    Posts
    640

    Re: _tcslen header file

    Hi!
    Very sorry for the late reply as i was not able to connect.
    Thanks ovidiucucu .

    I dont know but i ve been running into strange problems. When ever i try using sprintf the app crashes, here is what i ve been doing:

    Code:
    LPTSTR pszMessage = NULL;
    sprintf (pszMessage, "Hi!");
    The app also crahes when i use strcat, why is all this happening?

    Regards.
    "I rather not play football than wear Nerrazzuri shirt" - Paolo Maldini
    FORZA MILAN!!!

  5. #5
    Join Date
    May 2005
    Posts
    4,954

    Re: _tcslen header file

    Quote Originally Posted by logan
    dont know but i ve been running into strange problems. When ever i try using sprintf the app crashes, here is what i ve been doing:


    Code:
    LPTSTR pszMessage = NULL;
    sprintf (pszMessage, "Hi!");
    of course it will crash :-) LPTSTR is unallocated pointer and you are trying to ::sprintf to him!

    you have 2 options
    1)
    decalre TCHAR pszMessage[128]; // you will chose the size you want.

    2)
    LPTSTR pszMessage = new TCHAR[size you want];

    after that you can do whatever you want.

    if i helped dont forget to rate :-)
    Cheers

  6. #6
    Join Date
    May 2004
    Location
    Michigan, United States
    Posts
    457

    Re: _tcslen header file

    Also, if your going to use _tcslen() and TCHAR in order to be Unicode-safe, you'll probably want to use _stprintf() instead of sprintf() and _tcscat() instead of strcat().
    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured