Problem with WriteFile
-
Hi, I am sorry that I am asking a question not relevant to this section of MessageBoard, but I hope that somebody can help me out. I use the WriteFile function in my MFC application to write data to a File from a Buffer. When I see open the file, I see strange characters, while my data in the Buffer contains only numbers. What can be the problem? Thanks in Advance, Deepak Samuel
-
Hi, I am sorry that I am asking a question not relevant to this section of MessageBoard, but I hope that somebody can help me out. I use the WriteFile function in my MFC application to write data to a File from a Buffer. When I see open the file, I see strange characters, while my data in the Buffer contains only numbers. What can be the problem? Thanks in Advance, Deepak Samuel
A code snippet showing how you are writing to the file would be nice. How are you viewing the file once it's been written to?
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
-
Hi, I am sorry that I am asking a question not relevant to this section of MessageBoard, but I hope that somebody can help me out. I use the WriteFile function in my MFC application to write data to a File from a Buffer. When I see open the file, I see strange characters, while my data in the Buffer contains only numbers. What can be the problem? Thanks in Advance, Deepak Samuel
It depends on how you open the file. Do you open it as text or binary? If you open it as binary you would see strange characters because you would be seeing the ascii interpretation of what the numeric values are. For instantce if you output the number 32 as binary it would appear as a space in a text file.
-
A code snippet showing how you are writing to the file would be nice. How are you viewing the file once it's been written to?
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
hDataFile = CreateFile( DataFilename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); pWin_Data[0] = (PWINDATA)WinBuff_1_Address; WriteFile( hDataFile, pWin_Data[0], sizeof(ULONG), ptr, NULL ); CloseHandle( hDataFile); The File name is with the extension ".dat" and I opened it with notepad. Deepak Samuel.
-
hDataFile = CreateFile( DataFilename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); pWin_Data[0] = (PWINDATA)WinBuff_1_Address; WriteFile( hDataFile, pWin_Data[0], sizeof(ULONG), ptr, NULL ); CloseHandle( hDataFile); The File name is with the extension ".dat" and I opened it with notepad. Deepak Samuel.
It looks like your code is writing a pointer address to the file. Is this the intention? If you want what the pointer is pointing to, use *(pWin_Data[0]) Roger Allen - Sonork 100.10016 If your dead and reading this, then you have no life!