0
#include <stdio.h>

int main() {
    printf("x1\n");
    return 0;
}

I want to add the 1 character to bottom of x like in HTML. Is it possible in C?

<!DOCTYPE html>
<html>
    <head>
        <title></title>
    </head>

    <body>
        x<sub>1</sub>
    </body>
</html>
alk
  • 69,737
  • 10
  • 105
  • 255
NoWeDoR
  • 117
  • 8
  • 1
    Are you asking whether terminal window can handle subscript? – PM 77-1 Nov 25 '16 at 21:37
  • @PM 77-1 Exactly. – NoWeDoR Nov 25 '16 at 21:38
  • if you are working in console(terminal) it is impossible because console is in text mode (not graphics mode), but with some experience in memory editing, you can change unused characters and store your font. but there is only 255 chars (128-255 unused!). – SalmanAA Nov 25 '16 at 21:38
  • 1
    See http://stackoverflow.com/questions/597813/how-to-print-subscripts-superscripts-on-a-cli – PM 77-1 Nov 25 '16 at 21:40
  • 1
    Which code set are you using in your code, and which code set does your terminal expect? There is a Unicode character, U+2081, SUBSCRIPT ONE, which looks like ₁ in HTML (with luck) and displays fine on a terminal that handles an appropriate Unicode encoding (mine works with UTF-8). You might be able to use `"x\u2081\n"` to print that; it worked OK on macOS Sierra 10.12.1 with GCC 6.2.0 and the Terminal utility as the terminal. – Jonathan Leffler Nov 25 '16 at 22:09
  • @Jonathan Leffler I tried printf("x\u2081\n"); but it showed me x? on terminal (console). I'm using Windows 10 and Visual Studio. Thanks anyway. – NoWeDoR Nov 26 '16 at 12:38
  • That suggests that your terminal font doesn't have a glyph for subscript one. I'm not familiar with the Windows 10 terminal. That it prints one question mark suggests that it recognizes the byte sequence as a single character, rather than being confused about the three bytes in UTF-8 representing three characters. Sorry, I can't help more, I think. – Jonathan Leffler Nov 26 '16 at 17:20

1 Answers1

0

It's not possible here. Like you can see if needed we use sqrt function for root-over but there is no symbol.

  • 3
    This is not accurate in general — and without the qualifications needed to make it accurate (e.g. it depends on the terminal program, the operating system, the code sets that are in use), this is less than helpful as an answer. – Jonathan Leffler Nov 25 '16 at 22:11