我声明了一个字符数组指针
char* phone_num[];我现在要在phone_num中添加新的元素,0   1   2   3 等等,怎么写?

解决方案 »

  1.   

    char* phone_num[];
    是一个指针数组,如果是想用字符应该这样声明:
    char phone_num[43];
      

  2.   

    phone_num[0] = 0;
    就这么用
      

  3.   

    我就想达到这个效果
    char *phone_num[];
    phone_num=phone_num+'0';
    phone_num=phone_num+'3';
    phone_num=phone_num+'5';结果为:035我最后要用到*phone_num的,请问上面的过程正确格式该怎么写?
      

  4.   

    是变动的,我也不知道用户要输入多少
    phone_num=phone_num+'0';
    phone_num=phone_num+'3';
    phone_num=phone_num+'5';
    也可能是
    phone_num=phone_num+'0';
    phone_num=phone_num+'3';
    phone_num=phone_num+'5';
    phone_num=phone_num+'0';
    phone_num=phone_num+'3';
    phone_num=phone_num+'5';
      

  5.   

    既然是动态的,那么就用CByteArray动态数组好了。
      

  6.   

    呵呵,支持一下。
    List & Array都可以构成动态数组。
      

  7.   

    CByteArray
    The CByteArray class supports dynamic arrays of bytes. The member functions of CByteArray are similar to the member functions of class CObArray. Because of this similarity, you can use the CObArray reference documentation for member function specifics. Wherever you see a CObject pointer as a function parameter or return value, substitute a BYTE.CObject* CObArray::GetAt( int <nIndex> ) const;for example, translates toBYTE CByteArray::GetAt( int <nIndex> ) const;CByteArray incorporates the IMPLEMENT_SERIAL macro to support serialization and dumping of its elements. If an array of bytes is stored to an archive, either with the overloaded insertion (<<) operator or with the Serialize member function, each element is, in turn, serialized. Note   Before using an array, use SetSize to establish its size and allocate memory for it. If you do not use SetSize, adding elements to your array causes it to be frequently reallocated and copied. Frequent reallocation and copying are inefficient and can fragment memory.If you need debug output from individual elements in the array, you must set the depth of the CDumpContext object to 1 or greater.For more information on using CByteArray, see the articleCollections in Visual C++ Programmer's Guide.#include <afxcoll.h>Class Members |  Base Class |  Hierarchy ChartSee Also   CObArray