August 21st, 2003, 07:07 PM
Hi Guys and Gals,
I hope someone can help me get out of this situation.
Im converting a utility from console to win32, ,but im kinda stuck.
The utility reads a file and then creates 2 report files, the console version uses argv to read the file address where as i have created the open dialog(windows deefault)
The nest thing the console does is this:
if ((file_fd = open(file_address,O_BINARY|O_RDONLY)) == -1)
printf("Open_files error opening file %s\n",file_address);
this is when the file is opened, but the file_fd is an int.
Ive tried Createfile instead of open, but that doesnt seem to work with the right parameters.
Am i right in saying that this opens the file into memory allowing the rest of the program to access it and test for different things because this line is in a function called OpenTheFile.
Ive trried lots of things and nothing seems to work, any ideas???
August 21st, 2003, 08:44 PM
Instead of low-level I/O, try stream I/O. fopen(), fread(), fprintf(), fclose().
if ((fp = fopen(file_address,"rb")) == NULL)
// assuming MFC
s.Format("Open_files error opening file %s\n",file_address);
// or whatever function is needed for the message box.