本人现在想把已经提取出来的物体的中心点(CPoint类型)写到一个文档里面(.txt类型),不知道能不能用CFile::Write直接实现?如果不能我用下面的代码,但是文档里面怎么都是字符型? int nNumOfCenterPoint = pDoc->m_veCenterOfObject.size(); int *pCenterPoint = new int[2 * nNumOfCenterPoint]; for(int i = 0; i <  nNumOfCenterPoint;i++)
{
                 //存储物体中心点的横坐标和纵坐标
pCenterPoint[i*2] = pDoc->m_veCenterOfObject[i].x;
pCenterPoint[i*2+1] = pDoc->m_veCenterOfObject[i].y;
}        file.Write(pCenterPoint,2 * nNumOfCenterPoint );中间有些语句我省略了,应该不影响阅读;
    写入的文档打开是这样的:
   r   "   
    不知道哪位大虾能予以指教!!!
   谢了!

解决方案 »

  1.   

    CString str;
    for (int i=0; i<nNumOfCenterPoint; i++)
    {
       str.Format("%d,%d;",pCenterPoint[2*i],pCenterPoint[2*i+1]);
       file.Write((LPCSTR)str,str.GetLength);
    }
      

  2.   

    int nNumOfCenterPoint = pDoc->m_veCenterOfObject.size(); int *pCenterPoint = intchar[2 * nNumOfCenterPoint]; for(int i = 0; i <  nNumOfCenterPoint;i++)
    {
                     //存储物体中心点的横坐标和纵坐标
    pCenterPoint[i*2] = pDoc->m_veCenterOfObject[i].x;
    pCenterPoint[i*2+1] = pDoc->m_veCenterOfObject[i].y;
    }
    for(int i=0; i< nNumOfCenterPoint;i+=2)
    {CString str;
    str.Format("%d,%d\n",pCenterPoint[2*i],pCenterPoint[2*i+1]);
            file.Write(str,str.GetLength());
    }