Hi,I write something to make it put a string to a file and read it out
afterward.But i found when i write in a string : "TestingTextForWrite" to
that file,I can only read the first character of that string,that's "T"
only,may I know how can i modify the code below to read the whole string i
write in that file?

CString Testing1;
CString Testing2 ;

Testing.Format(L"TestingTextForWrite");
//Write File Now
FILE *fp;
if((fp=fopen("\\Windows\\filename.dat","w"))==NULL)
{
MessageBox(L"File IO Error",L"Error");//error when no file found
}
fprintf(fp,"%s",Testing1);
fclose(fp);




//Read File
if((fp=fopen("\\Windows\\filename.dat","r"))=NULL)
{
MessageBox(L"File IO Error",L"Error");//error when no file found
}

fscanf(fp,"%s",Testing2);
fclose(fp);

//MessageBox(Testing2);
SetDlgItemText(IDC_TESTING,Testing2);

Re: String Problem!!!! by r_z_aret

r_z_aret
Thu Aug 21 13:15:52 CDT 2003

You wrote out a UNICODE (WHCAR) string, but tried to read it as ANSI
(char). I _know_ this confuses many people, so I do sympathisize. But
I'm feeling particularly grumpy right now about how often I see
similar questions. So I'm going to strongly suggest using google
(http://groups.google.com/advanced_group_search) to look up
UNICODE tchar
in this newsgroup.

UNICODE is _always_ defined for Windows CE/Pocket PC development, and
many ANSI versions of common functions are absent. So anyone
programming for Windows CE /Pocket PC really needs to understand this.

On Wed, 20 Aug 2003 23:05:25 +0800, "Steven" <steven_cong@hotmail.com>
wrote:

>Hi,I write something to make it put a string to a file and read it out
>afterward.But i found when i write in a string : "TestingTextForWrite" to
>that file,I can only read the first character of that string,that's "T"
>only,may I know how can i modify the code below to read the whole string i
>write in that file?
>
> CString Testing1;
> CString Testing2 ;
>
> Testing.Format(L"TestingTextForWrite");
> //Write File Now
> FILE *fp;
> if((fp=fopen("\\Windows\\filename.dat","w"))==NULL)
> {
> MessageBox(L"File IO Error",L"Error");//error when no file found
> }
> fprintf(fp,"%s",Testing1);
> fclose(fp);
>
>
>
>
> //Read File
> if((fp=fopen("\\Windows\\filename.dat","r"))=NULL)
> {
> MessageBox(L"File IO Error",L"Error");//error when no file found
> }
>
> fscanf(fp,"%s",Testing2);
> fclose(fp);
>
> //MessageBox(Testing2);
> SetDlgItemText(IDC_TESTING,Testing2);
>
>

-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret
PenFact, Inc.
500 Harrison Ave., Suite 3R
Boston, MA 02118
www.penfact.com