Thread: Reading From Text File

  1. #1

    Reading From Text File


    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?

  2. #2
    here is an picture of my program:

  3. #3
    train spotter
    Join Date
    Aug 2001
    near a computer
    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
      //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++;
      while(*pFile++ != ',');//skip the comma 
      iInt=atoi(pFile);//to get an int ect  
      while(*pFile++ != ',');//skip the comma 
    //and on
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. Reading Character at a time from a text file
    By Giania in forum C Programming
    Replies: 8
    Last Post: 02-25-2006, 03:17 PM
  5. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 02:59 PM