Reading & Writing ASCII data using WinCE 6.0 embedded, MFC, VS2005
-
1. března 2012 19:32
So far, I can only open and close the files. How to manipulate data in a formatted way? My code follows:
int data1 = 3;
int data2 = 4;
int data3 = 5;
HANDLE infileHnd, outfileHnd;
TCHAR *bufIN, *bufOUT;
bufIN = _T("\\in.txt");
bufOUT = _T(\\out.txt);
infileHnd = CreateFileW (bufIN, ...);
outfileHnd = CreateFileW(bufOUT, ...); //both files are open
>>>> How to have file read ASCII data above and write it to an ASCII file such as: 3 4 5 (1 row, 3 columns separated by spaces in file)
CloseHandle (infileHnd);
CloseHandle (outfileHnd); //both files are closed
Thanks much for your help. CM007
- Upravený CodeMan007 1. března 2012 19:33
- Upravený CodeMan007 1. března 2012 19:34
Všechny reakce
-
1. března 2012 21:25
On Thu, 1 Mar 2012 19:32:58 +0000, CodeMan007 wrote:
So far, I can only open and close the files. How to manipulate data in a formatted way? My code follows:
int data1 = 3;
int data2 = 4;
int data3 = 5;
HANDLE infileHnd, outfileHnd;
TCHAR *bufIN, *bufOUT;
bufIN = _T("\\in.txt <file://\\in.txt>");
bufOUT = _T(\\out.txt <file://\\out.txt>);
infileHnd = CreateFileW (bufIN, ...);
outfileHnd = CreateFileW(bufOUT, ...); //both files are open
How to have file read ASCII data above and write it to an ASCII file such as: 3 4 5 (1 row, 3 columns separated by spaces in file)
You need to read into and write from an explicitly char (ASCII) array. Once you've read in
the ASCII data, MultiByteToWideChar to translate to WCHAR (Unicode). Then you can use
standard string and character functions. When you're ready to write, use
WideCharToMultiByte to translate back to char (ASCII) and then write from that array to
the file.
CloseHandle (infileHnd);
CloseHandle (outfileHnd); //both files are closed
Thanks much for your help. CM007
-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).Robert E. Zaret
PenFact, Inc.
20 Park Plaza, Suite 400
Boston, MA 02116
www.penfact.com
r_z_aret@pen_fact.com
Useful reading (be sure to read its disclaimer first):
http://catb.org/~esr/faqs/smart-questions.html- Navržen jako odpověď Jesse JiangMicrosoft Contingent Staff, Moderator 5. března 2012 2:44
- Označen jako odpověď Jesse JiangMicrosoft Contingent Staff, Moderator 8. března 2012 1:49
-
1. března 2012 21:36
Hi Robert, thanks much for your reply. Will definitely try that.
CM007
-
8. března 2012 1:50Moderátor
Hi,
I marked Bob's reply as answer, if your issue have not been solved please unmark it and update more information about this issue.
Best regards,
Jesse
Jesse Jiang [MSFT]
MSDN Community Support | Feedback to us