How To Change Number Size In C++
-
06-thirty-2013 #1
Registered User
changing font size and colour
I would like to know how I change the colour of font and the size. The simple lawmaking beneath would be nice to see displayed on a white groundwork and the text red and bigger. Is this possible in the control prompt window and if so how
Lawmaking:
ane 2 3 4 five 6 7 viii 9 10 11 12 #include<stdio.h>int main(){printf("\due north"); printf("------------\due north"); printf("HELLO World\north"); printf("------------\n"); printf("\n");render (0);}
-
06-30-2013 #ii
Registered User
the easiest manner i found to modify WINDOWS CONSOLE font and background colors is past including WINDOWS.H, then using the command One time like whne yous declare a variable
Lawmaking:
HANDLE hConsole; hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
Code:
SetConsoleTextAttribute(hConsole, NUMBER);
groups of 16
outset 16, black background, then sixteen colors of text
second sixteen, side by side color background, then 16 colors of text
etcprepare a number, then print text so run across what colors it is, then change number and run again till yous get the desired colors!
this does Not change the entire background to a color, if you print "HELLO" the groundwork volition be the colour for Simply the 5 spaces that the messages are, and then the text would exist the reg colour.
hope this helps, and have fun!
-
06-30-2013 #3
and the hat of int overfl
-
06-xxx-2013 #4
Registered User
am I right in assuming I need to run my code in a WINDOWS CONSOLE currently I compile it in the command prompt which windows console do y'all recommend I use.
-
06-30-2013 #v
Registered User
command prompt IS the windows panel............
as command.exe (or CMD.exe depending on which windows you use) is what handles your "msdos" programs for console style, wither you telephone call the prompt first, or your program calls it to run.
Last edited by Crossfire; 06-thirty-2013 at 12:29 PM.
-
06-30-2013 #half dozen
Registered User
and then the CMD.exe I deceit modify the color or text size. stumped I am where do I write lawmaking and compile in c and be able to modify colour and size of text
-
06-30-2013 #vii
Registered User
Ordinarily, you write the code in an editor that comes with your compiler - that's what they hateful past "IDE" - Integrated Evolution Surroundings. And then, when you run your code, your console program volition automatically open a panel window - a DOS type window, aka "Command Prompt window", and that window will take it's own color for background and text, and font settings.
The IDE will also accept other tools for helping y'all code better and faster - typically all key words in C are highlighted for y'all in a dissimilar color, it will accept a debugger yous can use to stride through your code and sentry variable values, set up breakpoints you can run to, etc. It may even have a profiler.
You change the console window, by opening it, and then correct clicking on the acme bar of the window, and choosing either "Properties" or "Default". They both take the same settings for both color and font, simply any change you make will be temporary, (one fourth dimension merely), if you lot choose "Backdrop". For permanent changes, choose "Default", and make your changes there, and save them.
I'm old fashioned, so I similar the bluish background and white letters, and 8x12 font size.
Concluding edited by Adak; 06-30-2013 at 03:42 PM.
-
06-30-2013 #eight
SAMARAS
-
06-30-2013 #ix
Registered User
Originally Posted past piczim
i surrender, no more than help from me
-
07-01-2013 #x
Registered User
Originally Posted by Crossfire
-
07-01-2013 #xi
Registered User
Originally Posted by piczim
Code:
#include <stdio.h> #include <stdlib.h> #include <Windows.h> int GetFontSize(HANDLE windowHandle, COORD *size) { CONSOLE_FONT_INFOEX font = { sizeof(CONSOLE_FONT_INFOEX) }; if (!GetCurrentConsoleFontEx(windowHandle, 0, &font)) { return 0; } *size = font.dwFontSize; return 1; } int SetFontSize(HANDLE windowHandle, COORD size) { CONSOLE_FONT_INFOEX font = { sizeof(CONSOLE_FONT_INFOEX) }; if (!GetCurrentConsoleFontEx(windowHandle, 0, &font)) { return 0; } font.dwFontSize = size; if (!SetCurrentConsoleFontEx(windowHandle, 0, &font)) { render 0; } return 1; } int main(void) { HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); COORD size; if (GetFontSize(h, &size)) { /* Grow by 50% */ size.10 += (SHORT)(size.10 * .5); size.Y += (Brusk)(size.Y * .5); SetFontSize(h, size); } puts("Blah blah text"); return EXIT_SUCCESS; }
Final edited past sonjared; 07-01-2013 at 11:12 AM.
-
07-01-2013 #12
Registered User
Colours are quite easy. Just use the conio.h fucntions.
Changing fonts is much more than difficult. Basically the console isn't designed to handle mixed fonts. You tin can write your own console (medium hard), on elevation of the Windows GDI functions, or yous can hack into the console (very difficult), or you can just display text in a normal windows (relatively easy).
I'chiliad the author of MiniBasic: How to write a script interpreter and Bones Algorithms
Visit my website for lots of associated C programming resources.
https://github.com/MalcolmMcLean
-
07-01-2013 #thirteen
Registered User
Originally Posted past sonjared
-
07-01-2013 #14
Registered User
Originally Posted by piczim
-
07-01-2013 #15
Registered User
Originally Posted by sonjared
Source: https://cboard.cprogramming.com/c-programming/157954-changing-font-size-colour.html
Posted by: dennisalannow.blogspot.com
0 Response to "How To Change Number Size In C++"
Post a Comment