输出字符文字 { 以流C++
Outputting character literal { to fstream C++
我正在尝试写入C++文件的一部分,以将文本输出到要由gnuPlot读取的文件中。我想在我的输出文件中包含字符 { 和 },以便 gnuplot 可以以类似于 laTex 使用的样式读取它们。
我的代码的相关部分如下:
std::ofstream gnuplotFile2;
gnuplotFile2.open("FourierImages.gpi");
gnuplotFile2 << "set xlabel "Wavenumber (m^" << '\u007B' << "-1" << '} << ""n";
在这里,我同时使用了 \u007B 和 } 来尝试输出 { 或 }。我也尝试只包括"...(m^{-1})";和"...(m^\{-1\}\m";.
我的输出文件始终读取
set xlabel "Wavenumber (m^-1)"
它生成一个图形/图表,标签在上标中具有 - 字符,但 1 作为普通脚本。
如何将 { 和 } 字符输出到文件?我想要
set xlabel "Wavenumber (m^{-1})"
除非我遗漏了什么,否则只需使用字符 {
和 }
,就像这样
$ cat test.cc
#include <iostream>
#include <fstream>
int main() {
std::ofstream gnuplotFile2;
gnuplotFile2.open("FourierImages.gpi");
gnuplotFile2 << "set xlabel "Wavenumber (m^{" << "-1" << "})"n";
}
$ g++ test.cc && ./a.out && cat FourierImages.gpi
set xlabel "Wavenumber (m^{-1})"
相关文章:
- 键入特征以检查类型是否可从流和 MSVC 读取
- 从C++调用 Python 脚本以持续流式传输数据
- 如何正确设置 ios 标志以进行流操作?
- 如何组织 git 工作流以修复错误并同时引入新功能
- 以 60fps 的速度流式传输 Logitec C922,C++
- 如何使文件流以 UTF-8 C++读取
- 将流的缓冲区与NULLPTR交换以模拟移动
- 我们可以来回移动流的指针以输出到文件吗?
- 如何分离以C++执行的 Java 应用程序的 stdin/stout/stderr 流
- 如何重载流运算符以使用位于不同文件中的函数
- 急切地加载整个模型以估计张量流的内存消耗
- 通过 cin/cout 的协议单元测试 - 如何阻止流以等待内容?
- 程序流并以安全而雄辩的方式正确返回Main()
- 如何重载iostream运算符以在整个流上执行功能
- C++以十进制打印的模板化流字符
- 以二进制方式打开文件,以什么样的方式流式传输它
- 输出字符文字 { 以流C++
- 如何阻止读取c++字符串流以等待数据
- VC2008读取数据以流式传输GDI+
- 输出以流式传输精确的浮点数字