Question

How can I do cursor control with ANSI using escape sequences using Turbo C? Here I've provided a code, but it's not yet working in my TurboC.

main()
{
   while( getche() != '.' )
      printf("\x1B[B");
}
Was it helpful?

Solution

Apart from the possibility that that output may be line buffered (meaning nothing may appear until you send a newline), you should probably also ensure that ANSI.SYS is loaded, since it's the device driver responsible for interpreting those sequences.

But I'm wondering why you're doing this. From memory (admittedly pretty faded memory), Turbo C has calls for doing this sort of thing, gotoXY and clrscr and such.

OTHER TIPS

A way of putting escape character with printf() is:

printf("%c[B", 0x1b);

But usually (I don't know Turbo C), there are libraries for doing terminal related stuff in a portable way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top