Urgent! FileI/O Problem
-
Hi all, I am using Embedded Visual C++ 3.0 and MFC dialog mode for implementation. Firstly, if I want to read one line each time from a .txt file in Pocket PC, can I use the following code? char* data; data = NULL; fp=fopen("\\sip.txt","r"); while((!feof(fp)) && (fp != NULL)) { fscanf(fp, "%s", data); // Process the data here } fclose(fp); Then, if I want to get the typed message from an edit box in a MFC dialog box and write/ append it into the file each time a line, should I do this? CString asip; GetDlgItemText(INPUT_ASIP, asip); fp=fopen("\\sip.txt","a"); fprintf(fp, "%s\n", asip); fclose(fp); But I encounter a problem that the output file “sip” contains only the first character of the CString asip. How can I solve this? It’s really urgent as I have to hand the program before 26/3/2003 so please kindly help me. Many thanks!!! Wil
-
Hi all, I am using Embedded Visual C++ 3.0 and MFC dialog mode for implementation. Firstly, if I want to read one line each time from a .txt file in Pocket PC, can I use the following code? char* data; data = NULL; fp=fopen("\\sip.txt","r"); while((!feof(fp)) && (fp != NULL)) { fscanf(fp, "%s", data); // Process the data here } fclose(fp); Then, if I want to get the typed message from an edit box in a MFC dialog box and write/ append it into the file each time a line, should I do this? CString asip; GetDlgItemText(INPUT_ASIP, asip); fp=fopen("\\sip.txt","a"); fprintf(fp, "%s\n", asip); fclose(fp); But I encounter a problem that the output file “sip” contains only the first character of the CString asip. How can I solve this? It’s really urgent as I have to hand the program before 26/3/2003 so please kindly help me. Many thanks!!! Wil
The PocketPC only supports UNICOD through
TCHAR
, notchar
. You have to rewrite everything in order to useTCHAR
. -
The PocketPC only supports UNICOD through
TCHAR
, notchar
. You have to rewrite everything in order to useTCHAR
.ok, THX ! Wil
-
ok, THX ! Wil
Is it just me, or is this messaging system really typo-prone? I meant
UNICODE
, of course... ;) -
Is it just me, or is this messaging system really typo-prone? I meant
UNICODE
, of course... ;)"UNICOD" is a new scientifically engineered generic fish, guaranteed to be edible, even in Fance. ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends
-
"UNICOD" is a new scientifically engineered generic fish, guaranteed to be edible, even in Fance. ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends
John Simmons / outlaw programmer wrote: "UNICOD" is a new scientifically engineered generic fish, guaranteed to be edible, even in Fance. :laugh: If you ever come to Portugal, try the 1000 ways of cooking cod. D E L I C I O U S ;)
-
The PocketPC only supports UNICOD through
TCHAR
, notchar
. You have to rewrite everything in order to useTCHAR
.I don't think so. I've tested
char
on PocketPC with C/C++ runtime library (FILE*). It works normally.FILE * g; if (g=fopen("abc.txt","rt")) { char szStr[255]; fgets(szStr,255,g); CString strMsg; strMsg = "Read text: "; strMsg+= szStr; MessageBox(strMsg); }
Of course, the file is just in ANSI charset. ======================= Nothing is perfect -
I don't think so. I've tested
char
on PocketPC with C/C++ runtime library (FILE*). It works normally.FILE * g; if (g=fopen("abc.txt","rt")) { char szStr[255]; fgets(szStr,255,g); CString strMsg; strMsg = "Read text: "; strMsg+= szStr; MessageBox(strMsg); }
Of course, the file is just in ANSI charset. ======================= Nothing is perfectI'm not sure of what might be happening, but some of the functions might be expecting TCHAR* instead of char*, although the compiler should complain about this. Is there anything wrong in the file itself? Why not use MFC's CFile?