在头文件中声明了一个动态数组
CPtrArray      m_OrgData;从文件中读取数据
float temp[6000];//not too small ,size is 6000
for(int i=0;i<m_nTracesPerInline;i++)
{
   m_file.Read(temp,m_nSamplesPerTrace*sizeof(float));
  this->m_OrgData.Add(temp);
  int length=m_iwagc/(m_nSampleInterval/1000);
   Agc(temp,length,m_nSamplesPerTrace);}
这样我是想把从文件中读取到的数据保存到数组中,在调用AGC()函数,上面程序能够正常运行可是如果我想把数据取出来时在调用AGC()函数却抱错误
代码如下
float  *temp;
for(int i=0;i<m_OrgData.GetSize();i++)
{
   temp=(float*)m_OrgData.GetAt(i);
   int length=m_iwagc/(m_nSampleInterval/1000);  
    Agc(temp,length,m_nSamplesPerTrace);
 
}

解决方案 »

  1.   

    不用m_OrgData.GetSize //返回的占用空间的大小,跟内存分配有关,跟里面数据多少无关。
    而用m_OrgData.GetCount()就OK了。
      

  2.   

    没有GetCount();这个方法,我用m_nTracesPerInline也出错,出错是AGC()函数报的错误
      

  3.   

    AGC函数的参数为Agc(float* data, int iwagc, int nt)
      

  4.   

    怎么会没有GetCount()Base Class MembersCObject MembersConstructionCPtrArray Constructs an empty array for void pointers. Bounds GetCount Gets number of elements in this array.    //这里
    GetSize Gets number of elements in this array. 
    GetUpperBound Returns the largest valid index. 
    SetSize Sets the number of elements to be contained in this array. Operations FreeExtra Frees all unused memory above the current upper bound. 
    IsEmpty Determines of the array is empty. 
    RemoveAll Removes all the elements from this array. Element Access ElementAt Returns a temporary reference to the element pointer within the array. 
    GetAt Returns the value at a given index. 
    GetData Allows access to elements in the array. Can be NULL. 
    SetAt Sets the value for a given index; array is not allowed to grow. Growing the Array Add Adds an element to the end of the array; grows the array if necessary. 
    Append Appends another array to the array; grows the array if necessary. 
    Copy Copies another array to the array; grows the array if necessary. 
    SetAtGrow Sets the value for a given index; grows the array if necessary. Insertion/Removal InsertAt Inserts an element (or all the elements in another array) at a specified index. 
    RemoveAt Removes an element at a specific index. Operators operator [] 
      

  5.   

    那就是你的AGC()中有错误啊,