Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have tired and tried, but all i get is errors.

What I have tried:

Here is an example

#include <graphics.h>
 
main()
{
   int gd = DETECT, gm, x = 25, y = 25, font = 0;
 
   initgraph(&gd,&gm,"NULL");
 
   for (font = 0; font <= 10; font++)
   {
      settextstyle(font, HORIZ_DIR, 1);
      outtextxy(x, y, "Text with different fonts");
      y = y + 25;
   }
 
   getch();
   closegraph();
   return 0;
}


In function ‘int main()’:
warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
    initgraph(&gd,&gm,"NULL");
                            ^
error: ‘HORIZ_DIR’ was not declared in this scope
       settextstyle(font, HORIZ_DIR, 1);
                          ^
error: ‘settextstyle’ was not declared in this scope
       settextstyle(font, HORIZ_DIR, 1);
                                      ^
warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
       outtextxy(x, y, "Text with different fonts");
Posted
Updated 4-Apr-16 0:41am
v2

1 solution

To avoid the warnings add this line on top of your source file:
C++
# pragma GCC diagnostic ignored "-Wwrite-strings"


The initgraph call should probably be changed to pass NULL instead of the string parameter "NULL":
initgraph(&gd,&gm,NULL);


Finally to the bad news. It seems that the Linux porting of the BGI (Borland Graphics Interface) does not support text styles. The header file graphics.h includes another header file grtext.h which provides definitions for outtextxy() but not for settextstyle() and constants related to that function like HORIZ_DIR.

You might think about using other graphic interfaces than a Linux port of an outdated graphics driver interface that was initially provided with Turbo C/C++ for MS-DOS and Windows 95.
 
Share this answer
 
Comments
Member 12435024 4-Apr-16 18:30pm    
Well thank you for for helping me. It sucks that it does not support settextstyle

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900