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.
Printable View
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
Thanks Paul, that works well.
Zapper
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++.
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.