void split(const CString str,const CString bystr,CString *str_array)
{
int nLen = bystr.GetLength();
int preLoc = 0;
int nowLoc = 0;
int i=0;
while(true)
{
nowLoc = str.Find(bystr,preLoc);
if(nowLoc == -1&&preLoc == 0)
{
CString substr3=str;
*(str_array+i)=substr3;
i++;
break;
}
if(nowLoc == -1&&preLoc != 0)
{
CString substr2=str.Mid(preLoc);
*(str_array+i)=substr2;
i++;
break;
}
CString substr = str.Mid(preLoc,nowLoc-preLoc);
*(str_array+i)=substr;
i++;
preLoc=nowLoc + nLen;
}
}
template <class T>
std::string ConvertToString(T value)
{
std::ostringstream ss_liu;
ss_liu<<value;
return ss_liu.str();
}
void _stdcall selpoint(char* path,double* xx,double* yy,double* zz,int* kk)
{
CString FileIN;
CStdioFile FileInName;
CFileException e;
int i=0;
int position=0;
CString tmp_arr[8];
double tvx;
double tvy;
double tvz;
FileIN=path;
FileInName.Open(FileIN,CFile::modeRead,&e);//Open FileIN For Input As #FileInName
while(total_num>0)
{
FileInName.ReadString(valstr);
split(valstr,",",tmp_arr);
tvx=atof(tmp_arr[0]);
tvy=atof(tmp_arr[1]);
tvz=atof(tmp_arr[2]);
Proj3Dto2D(tvx,tvy,tvz);
position=(int(tvy)-1)*v_width+int(tvx);
if(-10<(int(tvy-1)))
{
*(xx+i)=atof(tmp_arr[0]);
*(yy+i)=atof(tmp_arr[1]);
*(zz+i)=atof(tmp_arr[2]);
i++;
}
else
{
if((position>=0) && (position<=v_width*v_height) && (*(formview+position)==0))
{
*(xx+i)=atof(tmp_arr[0]);
*(yy+i)=atof(tmp_arr[1]);
*(zz+i)=atof(tmp_arr[2]);
i++;
*(formview+position)=1;
}
}
total_num--;
}
*kk=i-1;
FileInName.Close();
delete formview;
//fclose(FileOutName);
}
在vb中用string就行,上例中还要注意的就是文件的处理.