Unless I'm missing something, just use the characters {
and }
, like this
$ 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})"