-
December 7th, 2010, 10:47 PM
#1
[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.
-
December 7th, 2010, 10:55 PM
#2
Re: Source code for various string functions
Originally Posted by zapper222
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
-
December 8th, 2010, 12:01 AM
#3
Re: Source code for various string functions
Thanks Paul, that works well.
Zapper
-
December 8th, 2010, 06:00 AM
#4
Re: [RESOLVED] Source code for various string functions
Originally Posted by zapper222
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++.
-
December 8th, 2010, 11:07 AM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|