CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2007
    Posts
    162

    [RESOLVED] Source code for various string functions

    I am looking for the source code for two string functions:
    1. _strnicmp
    2. strncpy_s

    I am wondering if the source code is included with the installation of vs2008 or if some way to find it on the installation disc.

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Source code for various string functions

    Quote Originally Posted by zapper222 View Post
    I am looking for the source code for two string functions:
    1. _strnicmp
    2. strncpy_s

    I am wondering if the source code is included with the installation of vs2008 or if some way to find it on the installation disc.
    1) Write a program that calls those functions.

    2) Compile that program in debug mode.

    3) Set a breakpoint on those functions, start the program in debug, and step into them (F11) when the breakpoint is hit.

    You will then see if a) you have the source code to the CRT and b) where the source code is located.

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Apr 2007
    Posts
    162

    Re: Source code for various string functions

    Thanks Paul, that works well.

    Zapper

  4. #4
    Join Date
    Oct 2009
    Posts
    577

    Smile Re: [RESOLVED] Source code for various string functions

    Quote Originally Posted by zapper222 View Post
    I am looking for the source code for two string functions:
    1. _strnicmp
    2. strncpy_s

    I am wondering if the source code is included with the installation of vs2008 or if some way to find it on the installation disc.
    The _strnicmp is a C runtime function which originally names as strnicmp (no _ prefix). For less good reasons MS has decided to add the _ prefix to some of the runtime functions (e. g. _itoa) what actually only makes it harder to write portable code. For some of these functions nevertheless the original naming is still available via a define macro like '#define itoa _itoa'
    and if not you could add such a macro to your code if necessary.

    For C runtime functions normally there is no source code available.

    The strncpy_s isn't a standard C function but an enhancement of MS with the goal to add 'safer' functions to some of the runtime functions. In my opinion the attempt also failed and had the only effect that MS Code became more proprietary compared with portable code. The plus on safeness was to add an additionally size argument to the functions what may help to prevent from crashing sometimes but also may help to prevent from detecting faulty code.

    The enhancements to C runtime normally were available in $(VCInstall)crt\src where $(VCInstall) is the installation directory of your Visual C++.

  5. #5
    Join Date
    Apr 2007
    Posts
    162

    Re: [RESOLVED] Source code for various string functions

    Thanks itsmeandnobodyelse, the crt directory was exactly what I was in search of and I was able to locate it using the code breaks that Paul described. I am going to look into that idea of macro definition you suggested.

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