CodePudding user response:
To the file. The Open (_T (" ts. TXT "),CodePudding user response:
The mistake is notBut when debugging to the
CodePudding user response:
Debug, see error in whereCodePudding user response:
Need to determine whether a file open success, try catch catch CFileExceptionCodePudding user response:
Your file path is wrong, '\' is replaced by '\ \'CodePudding user response:
Cstrings strPath=_T (" ");CFileDialog Open (TRUE, _T (" *.txt "), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T (" account file (*.txt) | *. TXT | All Files (*. *) | *. * | | "), NULL);
If (Open. DoModal ()==IDOK)
{
StrPath=Open. GetPathName ();//this is the path you want,
}
CStdioFile file;
if (! File. The Open (strPath, CFile: : modeReadWrite))
{
//find failed to open file
AfxMessageBox (" account file error ");
return;
}
CodePudding user response:
# 5 right, you had problems with the \ Administrator here should be \ \, estimates there are behind the path error, just blocked the invisible,CodePudding user response:
C + + Character ConstantsCharacter constants are one or more members of the "source Character set," the Character set in which a program is written, surrounded by single quotation marks ('). They are 2 represent the characters in the "execution Character set," the Character set on the machine where the program executes.
Microsoft press
For Microsoft c + +, the source and execution character sets are both ASCII.
END the Microsoft press
There are three kinds of character constants:
Normal character constants
Multicharacter constants
Wide - character constants
Note the Use wide - character constants in place of multicharacter constants to ensure portability.
Character constants are specified as one or more characters enclosed in single quotation marks. For example:
Char ch='x';//Specify normal character constant.
Int MBCH='ab';//Specify system - dependent
//multicharacter constant.
Would be WCCH=L 'ab';//Specify wide - character constant.
Note that MBCH is of type int. If it were declared as type char, the second byte order not be retained. A multicharacter constant has four meaningful characters; Specifying more than four generates an error message.
Syntax
Character - constant:
'c - char - sequence'
L 'c - char - sequence'
C - char - sequence:
C - char
C - char - sequence c - char
C - char:
Any member of the source character set except the single quotation mark ('), the backslash (\), or newline character
The escape sequence -
The escape sequence:
Simple - the escape - sequence
Octal -- the escape sequence
Hexadecimal escape - sequence
Simple - the escape sequence: one of
\ \ '\ "? \ \
\ \ b \ \ f \ n \ r \ t v
Octal -- the escape sequence:
\ octal digit -
\ octal digit - octal digit -
\ octal digit - octal digit - octal digit -
Hexadecimal escape - sequence:
\ xhexadecimal - digit
Hexadecimal escape - sequence hexadecimal digit -
Microsoft C++ supports normal, multicharacter, and wide-character constants. Use wide-character constants to specify members of the extended execution character set (for example, to support an international application). Normal character constants have type char, multicharacter constants have type int, and wide-character constants have type wchar_t. (The type wchar_t is defined in the standard include files STDDEF.H, STDLIB.H, and STRING.H. The wide-character functions, however, are prototyped only in STDLIB.H.)
The only difference in specification between normal and wide - character constants is that wide - character constants are preceded by The letter l. For example:
Char schar='x';//Normal character constant
Would be wchar=L '\ x81 \ x19';//Wide - character constant
Table 1.2 shows the reserved or nongraphic characters that are system dependent or not allowed within character constants. These characters should be represented with the escape sequences.
Table 1.2 c + + Reserved or Nongraphic Characters
Character ASCII
Representation ASCII
The Value Escape Sequence
Newline NL (LF) or 10 0 x0a \ n
Horizontal TAB HT 9 \ t
Vertical TAB or 0 n 11 x0b \ v
Backspace BS 8 \ b
Carriage return 13 CR or 0 x0d \ r
12 or Formfeed FF x0c \ 0 f
Alert the BEL 7 \ a
92 or Backslash \ 0 x5c \ \
Question mark? 63 the or 0 x3f \?
Single quotation mark '39 or 0 x27 \'
A Double quotation mark "34 or 0 x22 "
Octal number ooo, ooo -
Hexadecimal number HHH - \ XHHH
A Null character NUL \ 0 0
nullnullnullnullnullnullnullnullnullnullnullnullnull