Need help for CFile read
Hi all, Can someone help me out with this? I would like to read from a file which contain alot of numbers and few letters.
I try out the code below.
f1.Open("C:/abc/t1", CFile::modeRead| CFile::shareExclusive);
int len = f1.GetLength();
char* buf = new char[len+1];
while(scanf(buf, "%lf %lf %lf\n", %a, %b, %c);
//read out the number and letter then do some compare and printf to a new FILE* f2
Using that code, my output result is diff from FILE* f1, fopen, and fscanf.
I am thinking whether is the problem due to scanf from char* cos if using FILE*, fscanf(f1, "%lf %lf %lf\n", %a, %b, %c); will be ok. That is scanf from file. For my CFile one, it is scanf from char*. So ??????
I need to use CFile cos i don't want other to open my file when my program is using it. Want to set some security. Please help me out. Thanks alot.
That scanf call looks suspicious. Shouldn't that be sscanf and shouldn't there be more parameters, for example the variables you want to read into?