现在我取得一个字符串如下:gs_dn=‘5971627’;现在我又取得了他的长度lendn=strlen(gs_dn)//7;我要得到一个字符串是由lendn+gs_dn组成的应该怎么来写??
也就是lendn+gs_dn应该是'75971627'可是我突然忘记了怎么来转int成string。。
请大家帮帮我了谢谢

解决方案 »

  1.   

    _itoa, _i64toa, _ui64toa, _itow, _i64tow, _ui64tow
    Convert an integer to a string.char *_itoa( int value, char *string, int radix );char *_i64toa( __int64 value, char *string, int radix );char * _ui64toa( unsigned _int64 value, char *string, int radix );wchar_t * _itow( int value, wchar_t *string, int radix );wchar_t * _i64tow( __int64 value, wchar_t *string, int radix );wchar_t * _ui64tow( unsigned __int64 value, wchar_t *string, int radix );Routine Required Header Compatibility 
    _itoa <stdlib.h> Win 95, Win NT 
    _i64toa <stdlib.h> Win 95, Win NT 
    _ui64toa <stdlib.h> Win 95, Win NT 
    _itow <stdlib.h> Win 95, Win NT 
    _i64tow <stdlib.h> Win 95, Win NT 
    _ui64tow <stdlib.h> Win 95, Win NT 
    For additional compatibility information, see Compatibility in the Introduction.LibrariesLIBC.LIB Single thread static library, retail version 
    LIBCMT.LIB Multithread static library, retail version 
    MSVCRT.LIB Import library for MSVCRT.DLL, retail version 
    Return ValueEach of these functions returns a pointer to string. There is no error return.ParametersvalueNumber to be convertedstringString resultradixBase of value; must be in the range 2 – 36ResThe _itoa, _i64toa, and _ui64toa function convert the digits of the given value argument to a null-terminated character string and stores the result (up to 33 bytes) in string. If radix equals 10 and value is negative, the first character of the stored string is the minus sign ( – ). _itow, _i64tow, and _ui64tow are wide-character versions of _itoa, _i64toa, and _ui64toa respectively. Generic-Text Routine MappingsTCHAR.H Routine  _UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Defined 
    _itot _itoa _itoa _itow 
    Example /* ITOA.C: This program converts integers of various
     * sizes to strings in various radixes.
     */#include <stdlib.h>
    #include <stdio.h>void main( void )
    {
       char buffer[20];
       int  i = 3445;
       long l = -344115L;
       unsigned long ul = 1234567890UL;   _itoa( i, buffer, 10 );
       printf( "String of integer %d (radix 10): %s\n", i, buffer );
       _itoa( i, buffer, 16 );
       printf( "String of integer %d (radix 16): 0x%s\n", i, buffer );
       _itoa( i, buffer, 2  );
       printf( "String of integer %d (radix 2): %s\n", i, buffer );   _ltoa( l, buffer, 16 );
       printf( "String of long int %ld (radix 16): 0x%s\n", l, 
                                                        buffer );   _ultoa( ul, buffer, 16 );
       printf( "String of unsigned long %lu (radix 16): 0x%s\n", ul,
                                                        buffer );
    }
    OutputString of integer 3445 (radix 10): 3445
    String of integer 3445 (radix 16): 0xd75
    String of integer 3445 (radix 2): 110101110101
    String of long int -344115 (radix 16): 0xfffabfcd
    String of unsigned long 1234567890 (radix 16): 0x499602d2
    Data Conversion RoutinesSee Also   _ltoa, _ultoa
      

  2.   

    CString str;
    str.Format("%d%d",lendn,gs_dn);
      

  3.   

    CString ss;
    ss.Format("%d",lendn);
    自己再加一下就可以了.
      

  4.   

    int n=6
    char sz[10];
    CString str;
    sprintf(sz,"%d",n);
    str.Format("%d",n);
      

  5.   

    char sz[10];
    wsprintf(sz,"%d%s",strlen(gs_dn),gs_dn);
      

  6.   

    你可以试试下面几种方法(肯定可以的)
    1)
    CString string;   int a=100;
    string.Format("%d",a);
    // 此时string将会变为 "100"2)
    Example /* ITOA.C: This program converts integers of various
     * sizes to strings in various radixes.
     */#include <stdlib.h>
    #include <stdio.h>void main( void )
    {
       char buffer[20];
       int  i = 3445;
       long l = -344115L;
       unsigned long ul = 1234567890UL;   _itoa( i, buffer, 10 );
       printf( "String of integer %d (radix 10): %s\n", i, buffer );
       _itoa( i, buffer, 16 );
       printf( "String of integer %d (radix 16): 0x%s\n", i, buffer );
       _itoa( i, buffer, 2  );
       printf( "String of integer %d (radix 2): %s\n", i, buffer );   _ltoa( l, buffer, 16 );
       printf( "String of long int %ld (radix 16): 0x%s\n", l, 
                                                        buffer );   _ultoa( ul, buffer, 16 );
       printf( "String of unsigned long %lu (radix 16): 0x%s\n", ul,
                                                        buffer );
    }
    OutputString of integer 3445 (radix 10): 3445
    String of integer 3445 (radix 16): 0xd75
    String of integer 3445 (radix 2): 110101110101
    String of long int -344115 (radix 16): 0xfffabfcd
    String of unsigned long 1234567890 (radix 16): 0x499602d2