我想把数值型的数据转成字符型,该怎么办呀?比如:
把整型999 转成 字符型"999".

解决方案 »

  1.   

    #include <stdlib.h>
    main()
    {
      int i=999;
      char a[10];  itoa(i, a, 10);
    }
      

  2.   

    just paste a piece of MSDN,u'd see details via it!Data Conversion
    These routines convert data from one form to another. Generally these routines execute faster than conversions you might write. Each routine that begins with a to prefix is implemented as a function and as a macro. See Choosing Between Functions and Macros for information about choosing an implementation. Data-Conversion RoutinesRoutine Use 
    abs Find absolute value of integer 
    atof Convert string to float 
    atoi, _atoi64 Convert string to int 
    atol Convert string to long 
    _ecvt Convert double to string of specified length 
    _fcvt Convert double to string with specified number of digits following decimal point 
    _gcvt Convert double number to string; store string in buffer 
    _itoa, _i64toa, _itow, _i64tow Convert int to string 
    labs Find absolute value of long integer 
    _ltoa, _ltow Convert long to string 
    _mbbtombc Convert 1-byte multibyte character to corresponding 2-byte multibyte character 
    _mbcjistojms Convert Japan Industry Standard (JIS) character to Japan Microsoft (JMS) character 
    _mbcjmstojis Convert JMS character to JIS character 
    _mbctohira Convert multibyte character to 1-byte hiragana code 
    _mbctokata Convert multibyte character to 1-byte katakana code 
    _mbctombb Convert 2-byte multibyte character to corresponding 1-byte multibyte character 
    mbstowcs Convert sequence of multibyte characters to corresponding sequence of wide characters 
    mbtowc Convert multibyte character to corresponding wide character 
    strtod, wcstod Convert string to double 
    strtol, wcstol Convert string to long integer 
    strtoul, wcstoul Convert string to unsigned long integer 
    strxfrm, wcsxfrm Transform string into collated form based on locale-specific information 
    __toascii Convert character to ASCII code 
    tolower, towlower, _mbctolower Test character and convert to lowercase if currently uppercase 
    _tolower Convert character to lowercase unconditionally 
    toupper, towupper, _mbctoupper Test character and convert to uppercase if currently lowercase 
    _toupper Convert character to uppercase unconditionally 
    _ultoa, _ultow Convert unsigned long to string 
    wcstombs Convert sequence of wide characters to corresponding sequence of multibyte characters 
    wctomb Convert wide character to corresponding multibyte character 
    _wtoi Convert wide-character string to int 
    _wtol Convert wide-character string to long