Reading & Writing ASCII data using WinCE 6.0 embedded, MFC, VS2005
-
2012年3月1日 下午 07: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
- 已編輯 CodeMan007 2012年3月1日 下午 07:33
- 已編輯 CodeMan007 2012年3月1日 下午 07:34
所有回覆
-
2012年3月1日 下午 09: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- 已提議為解答 Jesse JiangMicrosoft Contingent Staff, Moderator 2012年3月5日 上午 02:44
- 已標示為解答 Jesse JiangMicrosoft Contingent Staff, Moderator 2012年3月8日 上午 01:49
-
2012年3月1日 下午 09:36
Hi Robert, thanks much for your reply. Will definitely try that.
CM007
-
2012年3月8日 上午 01:50版主
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

