Error incomplete universal character name \\U

妖精的绣舞 提交于 2019-12-01 05:12:19

"C:\Users\My Name\Desktop\test\input.txt"
The backslash (\) is a special character. You must escape it:
"C:\\Users\\My Name\\Desktop\\test\\input.txt".

EDIT: Alternately, use forward slashes (/). Windows doesn't care.

You need to escape your backslashes in the filename. In C++ string constants, backslash is an escape character which doesn't represent itself. To get a literal backslash, you need to use a double backslash \\.

\U is the prefix for a 32-bit Unicode escape sequence: you'd use something like "\U0010FFFF" to represent a high Unicode character. The compiler is complaining that \Users... is not a valid Unicode escape sequence, since sers... is not a valid hexadecimal number.

The fix is to use the string "C:\\Users\\My Name\\Desktop\\test\\input.txt".

You need to use double backslashes there. So "C:\\Users.... Otherwise you're starting an escape sequence (in this case \U for a unicode literal).

You need to escape the \ with an extra \ in the file name . (i.e. you need to use \\)

it is exact case but, \U is not same meaning with \u. iOS accepts \u and it complains to \U

This error happens even in Visual Studio 2015 even if the text is in comments of your C/C++ source. Visual Studio is not smart enough to ignore this text in comments, even if the command is telling something useful (e.g. in the word domain\user and if this text is literally expected in e.g. a configuration file). Weird.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!