FILE *file = NULL; char path[]="D:\Data\Pos.csv"; CTime m_tDateTime; m_tDateTime = m_tDateTime.GetCurrentTime(); CString strTime = m_tDateTime.Format("%Y-%m-%d %H:%M:%S"); if (NULL != (file=fopen(path,"a"))) { fprintf(file,"%.3f,%.3f,%s",x,y,bexg?" ":""); } if(file != NULL) fclose(file);