Tuesday, August 29, 2017

C POINTERS - CIRCULAR DOUBLY LINKED LIST


A Simple Selection Menu in C with Ansi functions. 
This time I'm working on creating a circular list with pointers so as to display choice menus in C using colors to highlight the items. 
In my implementation, I have used 3 external global pointers (head, former and tail). That probably means that I can only create one list as these pointers are global variables.

















 Display:


Monday, August 28, 2017

We Love Colors - ANSI Functions II in C

You have several options to give your program a more attractive look in text-mode. Ncurses,for one, in Linux is an excellent choice. But if you want to keep it simple and do things fast, you can resort to using ANSI escape sequences. They work like a charm on Linux terminals. Unfortunately, its support was removed from Windows terminals. Although I hear Windows 10 has brought back support to these sequences. Alternatively, check Ansicon for windows support. 

From Wikipedia:


In C:

int gotoxy(int x,int y)
//Sets the cursor at the desired position.
{
  printf("%c[%d;%df",0x1B,y,x);
  return 0;
}

int outputcolor(int foreground, int background)
//Changes format foreground and background colors of display.
{
  printf("%c[%d;%dm", 0x1b,foreground,background);
  return 0;
}

int screencol(int x)
// Changes color of the entire screen.
{
  gotoxy(0,0);
  outputcolor(0,x);
  printf("%c[2J", 0x1b);
  outputcolor(0,0);
  return 0;
}