Search code examples
javac++cdouble-quotesapostrophe

How can I print a text in c/c++/java without double quotes and apostrophes in source code


How can I print a text for instance programming language without double quotes and apostrophes in source code? I made in c++ :

#include <iostream>
#define Rep(x) #x
int main()
{
   printf(Rep(programming language));
   return 0;
}

Program is ok but I wonder if there is another way to do this? and how do it in java? is any possibility do it in java?


Solution

  • Insert code units as integer literals:

    #include <iostream>
    
    int main() {
        char[] string = { 0x41, 0x42, 0x43, 0x0A, 0x00 };
        std::cout << string;
    }
    

    In Java this should do:

    byte[] bytes = {(byte)0x41, (byte)0x42, (byte)0x43, (byte)0x0A};
    String string = new String(bytes, "UTF-8");