Reading & Writing ASCII data using WinCE 6.0 embedded, MFC, VS2005
-
1 марта 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
- Изменено CodeMan007 1 марта 2012 г. 19:34
Все ответы
-
1 марта 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- Предложено в качестве ответа Jesse JiangMicrosoft Contingent Staff, Moderator 5 марта 2012 г. 2:44
- Помечено в качестве ответа Jesse JiangMicrosoft Contingent Staff, Moderator 8 марта 2012 г. 1:49
-
1 марта 2012 г. 21:36
Hi Robert, thanks much for your reply. Will definitely try that.
CM007
-
8 марта 2012 г. 1: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

