r***@yahoo.com
2007-06-16 05:28:32 UTC
Hi
I am having a typical problem from last one day.I am being able to
writ into a text file from my vc++ application,but I am not being able
to read the file.actually I need to write something in the file and I
need need to again read the file.here is y code which is working fine
for writing to file:
FILE *fp=NULL;
fp=_wfopen(lstr,_T("w+"));//lstr is having the path to the file
fwrite( strTitleCurrentDate, sizeof(TCHAR), strTitle.GetLength()/
** sizeof( TCHAR )*/, fp );
fclose( fp );
this code is working fine but
CString strTitle1;
newBuffer=strTitle1.GetBuffer(strTitle1.GetLength()*
sizeof( TCHAR ));
LPTSTR lstr=strPath2.GetBuffer(strTitle.GetLength()* sizeof( TCHAR ));
FILE *fp=NULL;
fp=_wfopen(lstr,_T("a+"));
while(!feof(fp))
fread( newBuffer, sizeof(char), 100/** sizeof( TCHAR )*/, fp );
fclose( fp );
This piece of code really meking me frustrated because the data in
file I am being able to read which actually should be "15th june 2007"
is coming as "15th june 2007SID",from where this SID is coming?One
more thing is that after this code of file reading if I take any
CString variable and try to display it in a message box,it is showing
the value "15th june 2007SID" whereas it should show blank.I am
getting crash also in my application may be due to this problem.Plz
help me to solve this problem with code,because it will help me a
lot.Plz help me as early as possible because the deadline is coming
and I am being frustrated.I also have to read data in a text file line
by line which is also not being possible for me.Plz help me with code.
I am having a typical problem from last one day.I am being able to
writ into a text file from my vc++ application,but I am not being able
to read the file.actually I need to write something in the file and I
need need to again read the file.here is y code which is working fine
for writing to file:
FILE *fp=NULL;
fp=_wfopen(lstr,_T("w+"));//lstr is having the path to the file
fwrite( strTitleCurrentDate, sizeof(TCHAR), strTitle.GetLength()/
** sizeof( TCHAR )*/, fp );
fclose( fp );
this code is working fine but
CString strTitle1;
newBuffer=strTitle1.GetBuffer(strTitle1.GetLength()*
sizeof( TCHAR ));
LPTSTR lstr=strPath2.GetBuffer(strTitle.GetLength()* sizeof( TCHAR ));
FILE *fp=NULL;
fp=_wfopen(lstr,_T("a+"));
while(!feof(fp))
fread( newBuffer, sizeof(char), 100/** sizeof( TCHAR )*/, fp );
fclose( fp );
This piece of code really meking me frustrated because the data in
file I am being able to read which actually should be "15th june 2007"
is coming as "15th june 2007SID",from where this SID is coming?One
more thing is that after this code of file reading if I take any
CString variable and try to display it in a message box,it is showing
the value "15th june 2007SID" whereas it should show blank.I am
getting crash also in my application may be due to this problem.Plz
help me to solve this problem with code,because it will help me a
lot.Plz help me as early as possible because the deadline is coming
and I am being frustrated.I also have to read data in a text file line
by line which is also not being possible for me.Plz help me with code.