轉義您的\
。在字符串中使用時必須是\\
。
FILE *f = fopen("R:\\abc.dat","r");
否則,該字符串由fopen
看到在包括\a
「警報」逃生這是一個無效的參數給它的序列。
常見轉義序列和它們的用途是:
\a The speaker beeping
\\ The backslash character
\b Backspace (move the cursor back, no erase)
\f Form feed (eject printer page; ankh character on the screen)
\n Newline, like pressing the Enter key
\r Carriage return (moves the cursor to the beginning of the line)
\t Tab
\v Vertical tab (moves the cursor down a line)
\’ The apostrophe
\」 The double-quote character
\? The question mark
\0 The 「null」 byte (backslash-zero)
\xnnn A character value in hexadecimal (base 16)
\Xnnn A character value in hexadecimal (base 16)
escape \,即它應該是\\ – mlt
除了使用下面回答的'\\'外,還可以使用正斜槓字符,即「R:/abc.dat」。 – gavinb