You are currently offline, waiting for your internet to reconnect

INFO: Map the C Run-Time (CRT) Library Functions to .NET Functions

This article was previously published under Q313836
SUMMARY
The following table lists the equivalent functions in .NET for functions in the standard C library. Locate the standard C function in the left column; the equivalent .NET function appears in the right column.

Note This is an approximate table. Some of the listed .NET functions are similar to the standard C functions, but the .NET function listed may not be an exact match. Also, if you use C++, replace the period character (.) with two colons (::).

If the function that you need is not listed in the table, refer to the More Information section of this article.

ARGUMENT ACCESS

STANDARD C FUNCTION               .NET EQUIVALENT FUNCTION---------------------------------------------------------------------------va_arg,va_end,va_start            ParamArray Attribute---------------------------------------------------------------------------

BUFFER MANIPULATION

STANDARD C FUNCTIONS              .NET EQUIVALENT FUNCTIONS---------------------------------------------------------------------------_memccpy,memcpy                   System.Buffer.BlockCopy,                                   System.String.Copymemchr,wmemchr                    System.String.CopyTomemcmp,memicmp                    System.Collections.Arraylist.BinarySearchmemmove                           System.String.Compare,                                   System.String.Equalsmemset                            System.Buffer.SetByte,                                  System.Collections.Arraylist.Item_swab                             n/a---------------------------------------------------------------------------

BYTE CLASSIFICATION

STANDARD C FUNCTIONS              .NET EQUIVALENT FUNCTIONS---------------------------------------------------------------------------_isleadbyte                  n/a but see System.Globalization.CultureInfo_ismbbalnum_ismbbalpha_ismbbgraph_ismbbkalnum_ismbbkana_ismbbkprint_ismbbkpunct_ismbblead_ismbbprint_ismbbpunct_ismbbtrail_ismbslead_ismbstrail_mbbtype_mbsbtype---------------------------------------------------------------------------

CHARACTER CLASSIFICATION

STANDARD C FUNCTIONS              .NET EQUIVALENT FUNCTIONS---------------------------------------------------------------------------isalnum, iswalnum                System.Char.IsLetterOrDigit_ismbcalnum                      n/aisalpha, iswalpha, _ismbcalpha,__isascii, iswascii              System.Char.IsLetteriscntrl, iswcntrl                System.Char.IsControl__iscsym, __iscsymf              System.Char.IsSymbolisdigit, iswdigit, _ismbcdigit   System.Char.IsDigitisgraph, iswgraph, _ismbcgraph   n/a	islower, iswlower, _ismbclower   System.Char.IsLower_ismbchira                       n/a_ismbckata                       n/a_ismbclegal                      n/a_ismbcl0                         n/a_ismbcl1                         n/a_ismbcl2                         n/a_ismbcsymbol                     n/aisprint, iswprint, _ismbcprint   n/a ispunct, iswpunct, _ismbcpunct   System.Char.IsPunctuationisspace, iswspace, _ismbcspace   System.Char.IsWhiteSpaceisupper, iswupper, _ismbcupper   System.Char.IsUpperiswctype                         System.Char.GetTypeisxdigit, iswxdigit              System.Char.IsNumbermblen                            n/a---------------------------------------------------------------------------

DATA CONVERSION

STANDARD C FUNCTIONS              .NET EQUIVALENT FUNCTIONS---------------------------------------------------------------------------abs                              System.Math.Absatof                             System.Convert.ToDoubleatoi                             System.Convert.ToInt32,                                 System.Convert.ToUInt32_atoi64                          System.Convert.ToInt64,                                 System.Convert.ToUInt64atol                             System.Convert.ToInt64,                                 System.Convert.ToUInt64_ecvt                            System.Convert.ToString_fcvt                            System.Convert.ToString_gcvt                            System.Convert.ToString_itoa, _i64toa, _itow, _i64tow   System.Convert.ToStringlabs                             System.Math.Abs_ltoa, _ltow                     System.Convert.ToString_mbbtombc                        n/a_mbcjistojms                     n/a_mbcjmstojis                     n/a_mbctohira                       n/a_mbctokata                       n/a_mbctombb                        n/ambstowcs                         n/ambtowc                           n/astrtod, wcstod                   System.Convert.ToDoublestrtol, wcstol                   System.Convert.ToInt64strtoul, wcstoul                 System.Convert.ToUInt64strxfrm, wcsxfrm                 System.Iformattable.ToString__toasciitolower, towlower, _mbctolower   System.Char.ToLower_tolower                         System.String.ToLowertoupper, towupper, _mbctoupper   System.Char.ToUpper,_toupper                         System.String.ToUpper_ultoa, _ultow                   System.Convert.ToStringwcstombs                         n/awctomb                           n/a_wtoi                            n/a_wtol                            n/a---------------------------------------------------------------------------

DEBUG

STANDARD C FUNCTIONS              .NET EQUIVALENT FUNCTIONS---------------------------------------------------------------------------_ASSERT, _ASSERTE                System.Diagnostics.Debug.Assert_CrtCheckMemory                  System.Diagnostics.PerformanceCounter_CrtDbgReport                    System.Diagnostics.Debug.Write,                                 System.Diagnostics.Debug.Writeline,                                 System.Diagnostics.Debug.WriteIf,                                 System.Diagnostics.Debug.WriteLineIf_CrtDoForAllClientObjects        n/a_CrtDumpMemoryLeaks              n/a_CrtIsValidHeapPointer           n/a_CrtIsMemoryBlock                n/a_CrtIsValidPointer               n/a_CrtMemCheckpoint                n/a_CrtMemDifference                n/a_CrtMemDumpAllObjectsSince       n/a_CrtMemDumpStatistics            System.Diagnostics.PerformanceCounter_CrtSetAllocHook                 n/a_CrtSetBreakAlloc                n/a_CrtSetDbgFlag                   n/a_CrtSetDumpClient                n/a_CrtSetReportFile                n/a_CrtSetReportHook                n/a_CrtSetReportMode                n/a_RPT[0,1,2,3,4]                  n/a_RPTF[0,1,2,3,4]                 n/a_calloc_dbg                      n/a_expand_dbg                      n/a_free_dbg                        n/a_malloc_dbg                      n/a_msize_dbg                       n/a_realloc_dbg                     n/a---------------------------------------------------------------------------

DIRECTORY CONTROL

STANDARD C FUNCTIONS              .NET EQUIVALENT FUNCTIONS---------------------------------------------------------------------------_chdir, _wchdir              System.Environment.CurrentDirectory_chdrive                     System.Environment.CurrentDirectory_getcwd, _wgetcwd            System.Environment.CurrentDirectory_getdcwd, _wgetdcwd          System.Environment.CurrentDirectory_getdrive                    System.Environment.CurrentDirectory_mkdir, _wmkdir              System.IO.Directory.CreateDirectory,                             System.IO.DirectoryInfo.CreateSubdirectory_rmdir, _wrmdir              System.IO.Directory.Deletesearchenv, _wsearchenv       n/a---------------------------------------------------------------------------

ERROR HANDLING

STANDARD C FUNCTIONS              .NET EQUIVALENT FUNCTIONS---------------------------------------------------------------------------assert macro                 n/a_ASSERT, _ASSERTE macros     System.Diagnostics.Debug.Assertclearerr                     n/a_eof                         n/afeof                         n/aferror                       n/a_RPT, _RPTF macros           n/a---------------------------------------------------------------------------

EXCEPTION HANDLING

STANDARD C FUNCTIONS              .NET EQUIVALENT FUNCTIONS---------------------------------------------------------------------------_set_se_translator           n/aset_terminate                n/aset_unexpected               n/aterminate                    n/aunexpected                   System.Exception---------------------------------------------------------------------------

FILE-HANDLING ROUTINES (File Handle)

STANDARD C FUNCTIONS              .NET EQUIVALENT FUNCTIONS---------------------------------------------------------------------------chsize                        System.IO.Stream.SetLength,                              System.IO.FileStream.SetLength_filelength                   System.IO.Stream.SetLength,                               System.IO.FileStream.SetLength_fstat, _fstati64             n/a_isatty                       System.IO.Stream.CanWrite,                               System.IO.FileStream.CanWrite_locking                      System.IO.Stream.Lock,                               System.IO.FileStream.Lock_setmode                      see System.IO.BinaryReader,                               System.IO.TextReader---------------------------------------------------------------------------

FILE-HANDLING ROUTINES (Path or File Name)

STANDARD C FUNCTIONS              .NET EQUIVALENT FUNCTIONS---------------------------------------------------------------------------_access, _waccess             System.IO.FileAccess_chmod, _wchmod               System.IO.File.SetAttributes,                               System.Security.Permissions.FileIOPermission_fullpath, _wfullpath         System.IO.File.Create_get_osfhandle                n/a_makepath, _wmakepath         System.IO.File.Create_mktemp, _wmktemp             n/a_open_osfhandle               System.IO.FileStream.Handleremove, _wremove              System.IO.File.Removerename, _wrename              System.IO.File.Move_splitpath, _wsplitpath       n/a_stat, _stati64,              System.IO.File.GetAttributes, _wstat, _wstati64             System.IO.File.GetCreationTime,                              System.IO.File.GetLastAccessTime,                               System.IO.File.GetLastWriteTime_umask                        System.IO.File.SetAttributes_unlink, _wunlink             System.IO.File.Remove---------------------------------------------------------------------------

FLOATING-POINT SUPPORT

STANDARD C FUNCTIONS              .NET EQUIVALENT FUNCTIONS---------------------------------------------------------------------------abs                           System.Math.Absacos                          System.Math.Acosasin                          System.Math.Asinatan, atan2                   System.Math.Atan, System.Math.Atan2atof                          System.Convert.ToInt64,                               System.ConvertToUInt64,                              System.Convert.ToSingle,                              System.Convert.ToDoubleBessel functions_cabsceil                          System.Math.Ceiling_chgsign                      n/a_clear87, _clearfp            n/a_control87, _controlfp        n/a_copysign                     n/acos, cosh                     System.Math.Cos, System.Math.Coshdifftime                      System.DateTime.Subtractdiv                           n/a_ecvt                         System.Convert.ToStringexp                           System.Math.Expfabs                          System.Math.Abs_fcvt                         System.Convert.ToString_finite                       System.Double.IsInfinityfloor                         System.Math.Floorfmod                          System.Math.IEEERemainder_fpclass                      System.Double.IsInfinity,                               System.Double.IsNegativeInfinity,                              System.Double.IsPositiveInfinity,                               System.Double.IsNan_fpieee_flt                   n/afrexp                         n/a_gcvt                         System.Convert.ToString_hypot                        n/a_isnan                        System.Double.IsNanlabs                          System.Math.Absldexp                         System.Math.Powldiv                          n/a  log                           System.Math.Loglog10                         System.Math.Log10_logb_lrotl, _lrotr                n/a_matherr                      n/a__max                         System.Math.Max__min                         System.Math.Minmodf                          n/anextafter                              n/apow                           System.Math.Powprintf, wprintf               System.Console.Write,                               System.Console.WriteLinerand                          System.Random_rotl, _rotr                  n/a _scalb                        n/ascanf, wscanf                 System.Console.Write,                              System.Console.WriteLinesin, sinh                     System.Math.Sin, System.Math.Sinhsqrt                          System.Math.Sqrtsrand                         System.Random_status87, _statusfp          n/astrtod                        System.Convert.ToDoubletan, tanh                     System.Math.Tan, System.Math.Tanh--------------------------------------------------------------------------

INPUT AND OUTPUT

STANDARD C FUNCTIONS              .NET EQUIVALENT FUNCTIONS---------------------------------------------------------------------------_open, fopen,                 System.IO.File.Open, freopen, _fsopen              System.IO.FileStream.Openfwprintf, fwscanf,            System.Stream.Write, System.Stream.WriteLine,fgetwc, fputwc, fgetws,       System.Console.Read, fputws                        System.Console.ReadLine                                                            clearerr                      n/afclose, _fcloseall            System.IO.FileStream.Close,                               System.IO.Stream.Close,                              System.IO.BinaryReader.Close,                              System.IO.BinaryWriter.Close,                              System.IO.TextReader.Close,                              System.IO.TextWriter.Close,                              System.IO.StringReader.Close,                              System.IO.StringWriter.Close,                              System.IO.StreamReader.Close,                              System.IO.StreamWriter.Close_fdopen, wfdopen              System.IO.FileStream.FileStreamfeof                          System.IO.FileStream.File.Readferror                        n/afflush                        System.IO.FileStream.Flushfgetc, fgetwc                 System.IO.FileStream.ReadByte_fgetchar, _fgetwchar         System.IO.BinaryReader.Read,                               System.IO.TextReader.Read,                              System.IO.StringReader.Read,                              System.IO.StreamReader.Readfgetpos, fgets, fgetws        System.IO.FileStream.Seek_fileno                       System.IO.FileStream.Handle_flushall                     System.IO.FileStream.Flush,                               System.IO.StreamWriter.Flush,                              System.IO.TextWriter.Flush,                               System.IO.StringWriter.Flush,                              System.IO.BinaryWriter.Flushfopen, _wfopen                System.IO.File.Openfprintf, fwprintf             System.IO.TextWriterfputc, fputwc,_fputchar,_fputwchar                    n/afputs, fputws                 n/afread                         n/afreopen, _wfreopen            System.IO.File.Openfscanf, fwscanf               n/afseek                         n/afsetpos                       System.IO.FileStream.Seek_fsopen, _wfsopen             n/aftell                         n/afwrite                        n/agetc, getwc                   n/agetchar, getwchar             n/agets, getws                   n/a_getw                         n/aprintf, wprintf               n/aputc, putwc                   n/aputchar, putwchar             n/aputs, _putws                  n/a_putw                         n/arewind                        n/a_rmtmp                        n/ascanf, wscanf                 n/asetbuf                        n/a _setmaxstdio                  n/asetvbuf                       n/a_snprintf, _snwprintf         n/aswprintf                      n/asscanf, swscanf               n/a_tempnam, _wtempnam           n/atmpfile                       n/atmpnam, _wtmpnam              n/aungetc, ungetwc               n/avfprintf, vfwprintf           n/avprintf, vwprintf             n/a_vsnprintf, _vsnwprintf       n/avsprintf, vswprintf           n/a---------------------------------------------------------------------------

INTERNATIONALIZATION

STANDARD C FUNCTION               .NET EQUIVALENT FUNCTION---------------------------------------------------------------------------Setlocale	              System.Globalization.CultureInfo---------------------------------------------------------------------------

MEMORY ALLOCATION

STANDARD C FUNCTIONS              .NET EQUIVALENT FUNCTIONS---------------------------------------------------------------------------_alloca                       n/a for allcalloc_calloc_dbg_expand_expand_dbgfree_free_dbg_get_sbh_threshold_heapadd_heapchk_heapmin_heapset_heapwalkmalloc	new_malloc_dbg_msize_msize_dbg_query_new_handler_query_new_moderealloc_realloc_dbg_set_new_handler_set_new_mode_set_sbh_threshold---------------------------------------------------------------------------

PROCESS AND ENVIRONMENT CONTROL

STANDARD C FUNCTIONS              .NET EQUIVALENT FUNCTIONS---------------------------------------------------------------------------abort                              n/aassert                             System.Diagnostics.Debug.Assert_ASSERT, _ASSERTE macros           System.Diagnostics.Debug.Assertatexit                             System.Diagnostics.Process.AddOnExit                                   (see Process.OnExit)_beginthread, _beginthreadex       System.Threading.Thread.Start_cexit,_c_exit                     System.Diagnostics.Process.CloseMainWindow_cwait                             System.Diagnostics.Process.WaitForExit_endthread, _endthreadex           n/a_execl, _wexecl                    n/a_execle, _wexecle                  n/a_execlp, _wexeclp                  n/a_execlpe, _wexeclpe                n/a_execv, _wexecv                    n/a_execve, _wexecve                  n/a_execvp, _wexecvp                  n/a_execvpe, _wexecvpe                System.Diagnostics.Process,                                   System.Diagnostics.ProcessInfoexit,_exit                         System.Diagnostics.Process.Killgetenv, _wgetenv                   System.Environment.GetEnvironmentVariable_getpid                            System.Diagnostics.Process.Id longjmp                            n/a_onexit                            System.Diagnostics.Process.OnExit_pclose                            n/aperror, _wperror                   n/a_pipe                              n/a_popen, _wpopen                    n/a_putenv, _wputenv                  n/araise                              n/asetjmp                             n/asignal                             n/a_spawnl, _wspawnl                  n/a_spawnle, _wspawnle                n/a_spawnlp, _wspawnlp                n/a_spawnlpe, _wspawnlpe              n/a_spawnv, _wspawnv                  n/a_spawnve, _wspawnve                n/a_spawnvp, _wspawnvp                n/a_spawnvpe, _wspawnvpe              n/a system, _wsystem                   System.Diagnostics.ProcessStartInfo,                                    System.Diagnostics.Process---------------------------------------------------------------------------

SEARCH AND SORTING

STANDARD C FUNCTIONS              .NET EQUIVALENT FUNCTIONS---------------------------------------------------------------------------bsearch                           System.Collections.ArrayList.BinarySearch_lfind                            System.Collections.ArrayList.Contains_lsearch                          n/aqsort                             System.Collections.ArrayList.Sort---------------------------------------------------------------------------

STRING MANIPULATION

STANDARD C FUNCTIONS              .NET EQUIVALENT FUNCTIONS---------------------------------------------------------------------------mbscoll, _mbsicoll,              System.String.Compare_mbsncoll, _mbsnicoll_mbsdec, _strdec, _wcsdec        n/a_mbsinc, _strinc, _wcsinc        n/a_mbslen                          n/a_mbsnbcat                        n/a_mbsnbcmp                        n/a_mbsnbcnt                        n/a_mbsnbcpy                        n/a_mbsnbicmp                       n/a_mbsnbset                        n/a_mbsnccnt                        n/a_mbsnextc, _strnextc, _wcsnextc  n/a_mbsninc. _strninc, _wcsninc     n/a_mbsspnp, _strspnp, _wcsspnp     n/a_mbstrlen                        n/asprintf, _stprintf               System.Console.Write,                                 System.Console.Writelinestrcat, wcscat, _mbscat          System.String.Concatstrchr, wcschr, _mbschr          n/astrcmp, wcscmp, _mbscmp          n/astrcoll, wcscoll,_stricoll, _wcsicoll,_strncoll, _wcsncoll             n/a_strnicoll, _wcsnicoll           System.String.Comparestrcpy, wcscpy, _mbscpy          System.String.Copystrcspn, wcscspn, _mbscspn       System.String.Substring_strdup, _wcsdup, _mbsdup        System.String.Clonestrerror,_strerror               System.Exception.Messagestrftime, wcsftime               System.Convert.ToString_stricmp, _wcsicmp, _mbsicmp     System.String.Comparestrlen, wcslen,                  System.String.Length_mbslen, _mbstrlen_strlwr, _wcslwr, _mbslwr        System.String.ToLowerstrncat, wcsncat, _mbsncat       System.String.Concatstrncmp, wcsncmp, _mbsncmp       System.String.Comparestrncpy, wcsncpy, _mbsncpy       System.String.Copywcsncpy, _mbsncpy                System.String.Copy_strnicmp, _wcsnicmp, _mbsnicmp  System.String.Compare_strnset, _wcsnset, _mbsnset     System.String.Replacestrpbrk, wcspbrk, _mbspbrk       n/astrrchr, wcsrchr,_mbsrchr        n/a_strrev, _wcsrev,_mbsrev         n/a_strset, _wcsset, _mbsset        n/astrspn, wcsspn, _mbsspn          System.String.Substringstrstr, wcsstr, _mbsstr          n/astrtok, wcstok, _mbstok          n/a_strupr, _wcsupr, _mbsupr        System.String.ToUpperstrxfrm, wcsxfrm                 n/avsprintf, _vstprint              n/a---------------------------------------------------------------------------

SYSTEM CALLS

STANDARD C FUNCTIONS              .NET EQUIVALENT FUNCTIONS---------------------------------------------------------------------------_findclose                       System.IO.Directory.GetFiles,_findfirst, _findfirsti64        System.IO.DirectoryInfo.GetFiles_wfindfirst, _wfindfirsti64      System.IO.DirectoryInfo.GetFileSystemInfos_findnext, _findnexti64          n/a_wfindnext, _wfindnexti64        n/a                                                 ---------------------------------------------------------------------------

TIME MANAGEMENT

STANDARD C FUNCTIONS              .NET EQUIVALENT FUNCTIONS---------------------------------------------------------------------------asctime, _wasctime               System.DateTime.ToLongDateString,                                  System.DateTime.ToLongTimeString,                                 System.DateTime.ToShortDateString,                                 System.DateTime.ToShortTimeString,                                  System.DateTime.ToStringclock                            n/actime, _wctime                   System.DateTime.GetDateTimeFormats,                                 System.DateTime.ToString,                                 System.DateTime.ToLongTimeString,                                  System.DateTime.ToShortTimeStringdifftime                         System.DateTime.Subtract_ftime                           System.DateTime.Now_futime                          System.IO.File.SetLastAccessTime,                                  System.IO.File.SetLastWriteTime,                                 System.IO.File.SetCreationTimegmtime                           System.DateTime.UtcNow,                                  System.DateTime.ToUniversalTimelocaltime                        System.DateTime.ToLocalTimemktime                           System.DateTime.DateTime_strdate, _wstrdate              System.DateTime.Parsestrftime, wcsftime,              System.DateTime.ToLongDateString, _strtime, _wstrtime              System.DateTime.ToLongTimeString,                                   System.DateTime.ToShortDateString,                                  System.DateTime.ToShortTimeString,                                  System.DateTime.ToStringtime                             n/a           _tzset                           n/a_utime, _wutime                  n/a
MORE INFORMATION
If the function that you need is not listed in the previous table, then you can use PInvoke to call the standard C function. For examples of how to use PInvoke, refer to the following Microsoft Developer Network (MSDN) article:
vc7 vc++.net vc++ .net
Properties

Article ID: 313836 - Last Review: 11/21/2005 17:01:57 - Revision: 3.3

  • Microsoft Visual C# .NET 2003 Standard Edition
  • Microsoft Visual C++ .NET 2003 Standard Edition
  • Microsoft Visual C# .NET 2002 Standard Edition
  • Microsoft Visual C++ .NET 2002 Standard Edition
  • kbdevstudio kbinfo KB313836
Feedback