Hello,
I am currently working on a project for work. I am using Microsoft Visual C++ 6. I am needing to know how to read from a text file and make the text appear in the drop down boxes?
This is a discussion on Reading From Text File within the Windows Programming forums, part of the Platform Specific Boards category; Hello, I am currently working on a project for work. I am using Microsoft Visual C++ 6. I am needing ...
Hello,
I am currently working on a project for work. I am using Microsoft Visual C++ 6. I am needing to know how to read from a text file and make the text appear in the drop down boxes?
here is an picture of my program: http://darkeldar77.tripod.com/myrecentproject.gif
Code:char *sFile=NULL,//pointer to be alloced mem *pFile=NULL,//pointer to current pos in file *pString=NULL,//pointer to current pos in new string sText[64];//new string CreateFile()//to open it hMem=AllocMem(GetFileSize())//alloc for whole file sFile=(char*)GlobalLock(hMem)//lock the mem //file I/O is slow and risky on networked machines, ReadFile(GetFileSize())//read whole file in one go to sFile CloseFile()//leave open for as short time as poss pFile=sFile;//set to begining of text file while(pFile!='\0') //extract string to add. I use commas in my text files as can be saved as Excel .csv pString=sText;//set other pointer to string to fill in while((*pFile != '\n') &&(*pFile != '\r') &&(*pFile != '\0') &&(*pFile != ',')) *pString++ = *pFile++; *pString='\0'; while(*pFile++ != ',');//skip the comma iInt=atoi(pFile);//to get an int ect while(*pFile++ != ',');//skip the comma SetDlgItemText(GetWDlgItem(hDlg,ID_CTRL),sText) //and on FreeMem()
Last edited by novacain; 05-21-2002 at 12:29 AM.
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill