Export (0) Print
Expand All
3 out of 4 rated this helpful - Rate this topic

Run-Time Routines and .NET Framework Equivalents

Visual Studio .NET 2003

This section lists functions in the C run-time library and the equivalent functions in the .NET Framework.

Note   Some listed .NET Framework functions are only approximately equivalent to the corresponding C run-time functions. Also, when using C++, replace the period character (.) with two colons (::).

If the function that you need is not listed, then you can use PInvoke to call the standard C function. For more information, see Platform Invoke Examples.

The main categories of Microsoft run-time library routines are:

Argument Access

The following .NET Framework equivalents provide similar functionality of the C run-time library functions for accessing arguments.

CRT function .NET Framework equivalent
va_arg, va_end, va_start System.ParamArrayAttribute class

Buffer Manipulation

The following .NET Framework equivalents provide similar functionality of the C run-time library functions for buffer manipulation.

Byte Classification

The following .NET Framework equivalents provide similar functionality of the C run-time library functions for byte classification.

Character Classification

The following .NET Framework equivalents provide similar functionality of the C run-time library functions for character classification.

Data Conversion

The following .NET Framework equivalents provide similar functionality of the C run-time library functions for data conversion.

Debug

The following .NET Framework equivalents provide similar functionality of the C run-time library functions for debugging.

Directory Control

The following .NET Framework equivalents provide similar functionality of the C run-time library functions for directory control.

Error Handling

The following .NET Framework equivalents provide similar functionality of the C run-time library functions for error handling.

CRT function .NET Framework equivalent
_ASSERT, _ASSERTE Macros System.Diagnostics.Debug.Assert
clearerr Not applicable
_eof Not applicable
feof Not applicable
ferror Not applicable
_RPT, _RPTF Macros Not applicable

Exception Handling

The following .NET Framework equivalents provide similar functionality of the C run-time library functions for exception handling.

CRT function .NET Framework equivalent
_set_se_translator Not applicable
set_terminate Not applicable
set_unexpected Not applicable
terminate Not applicable
unexpected See System.Exception Class

File-Handling Routines (File Descriptor)

The following .NET Framework equivalents provide similar functionality of the C run-time library functions for file-handling using file descriptors.

File-Handling Routines (Path or File Name)

The following .NET Framework equivalents provide similar functionality of the C run-time library functions for file-handling using paths or file names.

Floating-Point Support

The following .NET Framework equivalents provide similar functionality of the C run-time library functions for floating-point support.

CRT function .NET Framework equivalent
abs, _abs64 System.Math.Abs
acos, acosf System.Math.Acos
asin, asinf System.Math.Asin
atan, atanf, atan2, atan2f System.Math.Atan, System.Math.Atan2
atof, _wtof, atoi, _wtoi, _atoi64, _wtoi64, atol, _wtol System.Convert.ToInt64, System.Convert.ToUInt64, System.Convert.ToSingle, System.Convert.ToDouble
Bessel Functions Not applicable
_cabs Not applicable
ceil, ceilf System.Math.Ceiling
_chgsign Not applicable
_clear87, _clearfp Not applicable
_control87, _controlfp Not applicable
_copysign Not applicable
cos, cosf, cosh, coshf System.Math.Cos, System.Math.Cosh
difftime System.DateTime.Subtract
div Not applicable
_ecvt System.Convert.ToString
exp, expf System.Math.Exp
fabs, fabsf System.Math.Abs
_fcvt System.Convert.ToString
_finite System.Double.IsInfinity
floor, floorf System.Math.Floor
fmod, fmodf System.Math.IEEERemainder
_fpclass System.Double.IsInfinity, System.Double.IsNegativeInfinity, System.Double.IsPositiveInfinity, System.Double.IsNan
_fpieee_flt Not applicable
frexp Not applicable
_gcvt System.Convert.ToString
_hypot, hypotf Not applicable
_isnan System.Double.IsNan
labs System.Math.Abs
ldexp System.Math.Pow
ldiv Not applicable
log, logf System.Math.Log
log10, log10f System.Math.Log10
_logb Not applicable
_lrotl, _lrotr Not applicable
_matherr Not applicable
__max System.Math.Max
__min System.Math.Min
modf, modff Not applicable
_nextafter Not applicable
pow, powf System.Math.Pow
printf, wprintf System.Console.Write, System.Console.WriteLine
rand See System.Random Class
_rotl, _rotl64, _rotr_rotr64 Not applicable
_scalb Not applicable
scanf, wscanf System.Console.Read, System.Console.ReadLine
sin, sinf, sinh, sinhf System.Math.Sin, System.Math.Sinh
sqrt, sqrtf System.Math.Sqrt
srand See System.Random Class
_status87, _statusfp Not applicable
strtod, wcstod System.Convert.ToDouble
tan, tanf, tanh, tanhf System.Math.Tan, System.Math.Tanh

Input and Output

The following .NET Framework equivalents provide similar functionality of the C run-time library functions for input and output.

CRT function .NET Framework equivalent
_open, _wopen, fopen, _wfopen, freopen, _wfreopen, _fsopen, _wfsopen System.IO.File.Open, System.IO.FileStream.FileStream
clearerr Not applicable
fclose, _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.FileStream
feof System.IO.FileStream.Read
ferror Not applicable
fflush System.IO.FileStream.Flush
fgetc, fgetwc System.IO.StreamReader.Read
_fgetchar, _fgetwchar System.Console.Read
fgetpos System.IO.FileStream.Position
fgets, fgetws System.IO.StreamReader.ReadLine, System.IO.TextReader.ReadBlock
_fileno System.IO.FileStream.Handle
_flushall System.IO.FileStream.Flush, System.IO.StreamWriter.Flush, System.IO.TextWriter.Flush, System.IO.BinaryWriter.Flush
fopen, _wfopen System.IO.File.Open
fprintf, fwprintf System.IO.StreamWriter.Write
fputc, fputwc System.IO.StreamWriter.Write
_fputchar, _fputwchar System.Console.Write
fputs, fputws System.IO.StreamWriter.Write
fread System.IO.FileStream.Read
freopen, _wfreopen System.IO.File.Open
fscanf, fwscanf System.IO.StreamReader.ReadLine; see also Parse methods, such as System.Double.Parse.
fseek System.IO.FileStream.Position, System.IO.FileStream.Seek
fsetpos System.IO.FileStream.Position
_fsopen, _wfsopen Not applicable
ftell System.IO.FileStream.Position
fwrite System.IO.FileStream.Write
getc, getwc System.IO.StreamReader.Read
getchar, getwchar System.Console.Read
gets, _getws System.Console.Read
_getw Not applicable
printf, wprintf System.Console.Write
putc, putwc System.IO.StreamWriter.Write
putchar, putwchar System.Console.Write
puts, _putws System.Console.Write
_putw Not applicable
rewind Not applicable
_rmtmp Not applicable
scanf, wscanf System.Console.ReadLine; see also Parse methods, such as System.Double.Parse.
setbuf Not applicable
_setmaxstdio Not applicable
setvbuf Not applicable
_snprintf, _snwprintf Not applicable
sprintf, swprintf System.String.Format
sscanf, swscanf See Parse methods, such as System.Double.Parse
_tempnam, _wtempnam, tmpnam, _wtmpnam Not applicable
tmpfile Not applicable
ungetc, ungetwc Not applicable
vfprintf, vfwprintf Not applicable
vprintf, vwprintf System.Console.Write
_vsnprintf, _vsnwprintf Not applicable
vsprintf, vswprintf System.String.Format

Internationalization

The following .NET Framework equivalents provide similar functionality of the C run-time library functions for internationalization.

CRT Function .NET Framework Equivalent
setlocale, _wsetlocale see System.Globalization.CultureInfo Class

Memory Allocation

Because the common language runtime provides automatic memory management (garbage collection), the .NET Framework has no equivalents for the memory allocation functions in the C run-time library.

Process and Environment Control

The following .NET Framework equivalents provide similar functionality of the C run-time library functions for process and environment control.

Searching and Sorting

The following .NET Framework equivalents provide similar functionality of the C run-time library functions for searching and sorting.

String Manipulation

The following .NET Framework equivalents provide similar functionality of the C run-time library functions for string manipulation.

CRT function .NET Framework equivalent
mbscoll, _mbsicoll, _mbsncoll, _mbsnicoll System.String.Compare
_mbsdec, _strdec, _wcsdec Not applicable
_mbsinc, _strinc, _wcsinc Not applicable
_mbsnbcat Not applicable
_mbsnbcmp Not applicable
_mbsnbcnt, _mbsnccnt, _strncnt, _wcsncnt Not applicable
_mbsnbcpy Not applicable
_mbsnbicmp Not applicable
_mbsnbset Not applicable
_mbsnextc, _strnextc, _wcsnextc Not applicable
_mbsninc, _strninc, _wcsninc Not applicable
_mbsspnp, _strspnp, _wcsspnp Not applicable
sprintf, swprintf System.String.Format
strcat, wcscat, _mbscat System.String.Concat
strchr, wcschr, _mbschr System.String.IndexOf
strcmp, wcscmp, _mbscmp System.String.CompareOrdinal
strcoll, wcscoll, _stricoll, _wcsicoll, _strncoll, _wcsncoll System.String.Compare
_strnicoll, _wcsnicoll System.String.Compare
strcpy, wcscpy, _mbscpy System.String.Copy
strcspn, wcscspn, _mbscspn System.String.Substring
_strdup, _wcsdup, _mbsdup System.String.Clone
strerror, _strerror, _wcserror, __wcserror System.Exception.Message
strftime, wcsftime System.Convert.ToString
_stricmp, _wcsicmp, _mbsicmp System.String.Compare
strlen, wcslen, _mbslen, _mbstrlen System.String.Length
_strlwr, _wcslwr, _mbslwr System.String.ToLower
strncat, wcsncat, _mbsncat System.String.Concat
strncmp, wcsncmp, _mbsncmp System.String.Compare
strncpy, wcsncpy, _mbsncpy System.String.Copy
_strnicmp, _wcsnicmp, _mbsnicmp System.String.Compare
_strnset, _wcsnset, _mbsnset System.String.Replace
strpbrk, wcspbrk, _mbspbrk System.String.IndexOfAny
strrchr, wcsrchr, _mbsrchr System.String.LastIndexOf
_strrev, _wcsrev, _mbsrev Not applicable
_strset, _wcsset, _mbsset Not applicable
strspn, wcsspn, _mbsspn System.String.Substring
strstr, wcsstr, _mbsstr System.String.IndexOf
strtok, wcstok, _mbstok Not applicable
_strupr, _wcsupr, _mbsupr System.String.ToUpper
strxfrm, wcsxfrm Not applicable
vsprintf, vswprintf System.String.Format

System Calls

The following .NET Framework equivalents provide similar functionality of the C run-time library functions for system calls.

Time Management

The following .NET Framework equivalents provide similar functionality of the C run-time library for time management.

See Also

Run-Time Library Reference | Managed Extensions for C++ Programming

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.