Home > Software engineering >  Why MFC reads the text file, reads all the data is zero?
Why MFC reads the text file, reads all the data is zero?

Time:09-15


Void CMy0823Dlg: : loadMap (int iMissionNum)
{cstrings STR.
STR. The Format (" [% d] ", iMi ssi onNum);
The FILE * pFile;
Fopen_ s (& amp; PFile, "map. TXT", "rb");
If (pFile==NULL)
return ;


Char cTmp [20].
The fgets (cTmp, 20, pFile);
While (STRNCMP (cTmp, STR, 3)!=0)
The fgets (cTmp, 20, pFile);


For (inti=0; i<14. I + t)
The fgets (m_ cMap [I], 20, pFile);
The fclose (pFile);
}


Also, the middle cTmp defined what's the use? The code on the net, have a problem with my in my program, small white sincerely ask,

CodePudding user response:

To set breakpoints, watching to see if the file open?
"Rb" (bin) into "rt" (TXT) try
Open to check the original file format is in accordance with the norms such as application UltraEdit

CodePudding user response:

reference 1st floor zgl7903 response:
set breakpoints, and see whether file open normal?
"Rb" (bin) into "rt" (TXT) try
Open to check the original file format is in accordance with the norms such as application UltraEdit

Is indeed a file open, there is something wrong with my heart changed or not, plug (' - omega? `)

CodePudding user response:

Your code is not whether the file already to EOF end-of-file?

CodePudding user response:

Try to use an absolute path such as "D: \ \ test \ a.t xt"

CodePudding user response:

reference 4 floor zgl7903 response:
try using absolute path such as "D: \ \ test \ a.t xt"

Or no, that isn't me files have a problem

CodePudding user response:

The
reference 3 floor 7-eleven's response:
your code is not whether the file already to EOF end-of-file?

I don't know... Without this will have an impact on program?

CodePudding user response:

refer to 6th floor mina_1978 response:
Quote: refer to the third floor 7-eleven's response:
your code is not whether the file already to EOF end-of-file?

I don't know... Without this will have an impact on program?

Will, you place the order with the Debug step performs the following, in addition you what is the contents of a text file format?

CodePudding user response:

refer to 7th floor 7-eleven's response:
Quote: refer to the sixth floor mina_1978 response:

Quote: refer to the third floor 7-eleven's response:
your code is not whether the file already to EOF end-of-file?

I don't know... Without this will have an impact on program?

Will, you place the order with the Debug step performs the following, in addition you what is the contents of a text file format?

[1]
0000000010100000000000

Almost like this, I put the map into array in inside,

CodePudding user response:

Do a simple program first, and see if I can open the file, and then read a particular string, and see if I can properly execute your program

CodePudding user response:

Data should be 0, read more, it is not zero

CodePudding user response:

If more bytes and bytes wide different influence
  • Related