Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reading from a file 1

Status
Not open for further replies.

jl3574

Programmer
Joined
Jun 5, 2003
Messages
76
Location
CA
i created an simple binary query database with an interface and a simple import file button
however i need to keep trace how many times a file is being imported as when time the button pressed the program will terminate. since i can't keep a count using a varaible inside the program cause variables reset after the program terminates i was thinking of using another file to keep track with an array or somthing? and each time the program runs it would check which file number i'm at? so how would i code this? or is there a better way?
pls help...
 
You can use the CFile class to read files.
Here is a little example:

CFile file;
int filenum;

//if not exist, create.
if (file.Open( "filenum.dat", CFile::modeReadWrite))
file.read(&filenum, sizeof(int));
else
{
file.Open( "filenum.dat", CFile::modeCreateCFile::modeReadWrite);
filenum = 0;
}

// enter your code here
// when you close the program, write the variable to
// the file
file.Write(&num, sizeof(int));
file.Close();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top