This blog is under construction

Saturday, 14 September 2013

settextjustify example in c

Header file:
    graphics.h

Synopsis:
      void settextjustify(int horizontal, int vertical);
     
Description:
     settextjustify() sets text justification(horizontally and vertically) for the current graphic mode.


settextjustify function in c graphics



  #include <graphics.h>
  #include <stdlib.h>
  #include <string.h>
  #include <stdio.h>
  #include <conio.h>
  #include <dos.h>

  int main(void) {
        /* request auto detection */
        int graphicDriver = DETECT, graphicMode;
        int err;

        /* initialize graphics and local variables */
        initgraph(&graphicDriver, &graphicMode,
                        "C:/TURBOC3/BGI");

        /* read result of initialization */
        err = graphresult();

        /* an error occurred */
        if (err != grOk) {
                printf("Graphic Error: %s\n",
                                grapherrormsg(err));
                return 0;
        }

        /* setting the current drawing color */
        setcolor(10);

        /* setting text justification  - horizontally & vertically */
        settextjustify(CENTER_TEXT, CENTER_TEXT);

        /* setting the text styles */
        settextstyle(SANS_SERIF_FONT, HORIZ_DIR, 20);

        /* output given text at the given position */
        outtextxy(getmaxx() / 2, getmaxy() / 2, "HOW R U?");

        /* clean up */
        getch();
        closegraph();
        return 0;
  }





Output: (settextjustify built-in function in c graphics.h)


No comments:

Post a Comment