i need to be able to add data to my .dat file without deleting my old data during a program run can anyone help me?
If this is a console app (DOS program) or UNIX program that outputs to standard output, you could redirect the output to your data file
program.exe >> datafile.dat
If this is a Windows program, you can use CreateFile with the following arguments
HANDLE hFile = INVALID_HANDLE_VALUE;
hFile = CreateFile("yourfile.dat",
GENERIC_READ | GENERIC_WRITE,
0, // no file sharing
NULL, // no security descriptor
OPEN_ALWAYS, // creates if not found
NULL); // No template handle
This returns a HANDLE that you can pass to ReadFile and WriteFile
Using SetFilePointer if you need to position to any part of the file.
if (hFile != INVALID_HANDLE_VALUE)
if (FALSE == WriteFile(hFile,
dataBuffer, // data to write
NULL)) // not using overlapped I/O
"Error", "Error", MB_ICONSTOP);
// will want to verify
// bytesWritten == dataBufferSize
I am working creating a fully encapsulated, homogeneous singly linked data structure. The Listing class and SinglyLinkedList class that are part of the whole application compile fine, but the problem ...