错误不完整的通用字符名称\U [英] Error incomplete universal character name \U
本文介绍了错误不完整的通用字符名称\U的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想写一个改变.txt文件的C ++程序。但是,当我运行它,我得到一个奇怪的错误。
I'm trying to write a C++ program that alters a .txt file. However when I run it I get a strange error.
错误:
6:20 C:\Dev-Cpp \Homework6.cpp不完全通用字符名称\U
6:20 C:\Dev-Cpp\Homework6.cpp incomplete universal character name \U
我的代码: / p>
My code:
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ofstream myfile ("C:\Users\My Name\Desktop\test\input.txt");
if (myfile.is_open())
{
myfile << "This is a line.\n";
myfile << "This is another line.\n";
myfile.close();
}
else cout << "Unable to open file";
return 0;
}
我做错了什么?
推荐答案
C:\Users\ My Name \Desktop\test\input .txt
反斜杠( \
)是一个特殊字符。您必须转义它:
C:\\Users\\ My Name\\Desktop\\\\\input.txt
。
"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"
.
编辑:或者,使用正斜杠( /
)。 Windows不在乎。
Alternately, use forward slashes (/
). Windows doesn't care.
这篇关于错误不完整的通用字符名称\U的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文