elroulianito
Messages postés17Date d'inscriptionlundi 27 janvier 2003StatutMembreDernière intervention31 janvier 2009
-
12 mai 2003 à 16:55
BruNews
Messages postés21040Date d'inscriptionjeudi 23 janvier 2003StatutModérateurDernière intervention21 août 2019
-
12 mai 2003 à 17:08
voila g déposer une source comportant une fonction qui a besoin d'être écrite proprement.
(l'appli fonctionne et tous les fichiers du projet sont dispo)
voila la fonction très vilaine:
void CDlg_textDlg::OnSave()
FILE *fp;
int nFileLong;
double X,Y,Z;
UpdateData(TRUE); //Force data from Edit box to variable
if (m_ldFile.DoModal() == IDOK) //Start file dlg box
{
int NumberOfLines=0;
m_sOutputFileName=m_ldFile.GetPathName(); //Get file name
m_fileOut=m_sOutputFileName;
fstream input(m_sFileName,ios::in);
fstream output(m_sOutputFileName,ios::out);
nFileLong = m_stringIn.GetLength(); //Length of text in Edit box
//C la la que ça devient moche: après fstream input( xxx),fp=fopen(xxx)
fp=fopen(m_sOutputFileName,"rb"); //Open file for reading
fseek(fp,0,SEEK_END); //Go to file end
nFileLong=ftell(fp); //Get length
char* sText = new char[nFileLong+1];//reserve string space
fseek(fp,0,SEEK_SET); //Go to file start
int j=fread(sText,1,nFileLong,fp); //Read the characters
sText[j]=0; //Set string terminating null
m_stringOut=sText; //Put text in Edit box's variable
m_string=m_stringOut;
fclose(fp);
BruNews
Messages postés21040Date d'inscriptionjeudi 23 janvier 2003StatutModérateurDernière intervention21 août 2019 12 mai 2003 à 17:08
en MFC ??? donc Win32 exclusif, OK ???
Alors que font encore la ces flux obsoletes ?
Remplace par API Win32:
CreateFile();
ReadFile();
WriteFile();
SetFilePointer();
GetFileSize();
CloseHandle();
BruNews, ciao...