Basilcally C and C++ Supports two Different Modes.....
1) Text Mode
2) Graphics Mode
( This Tutorial is all about text Mode)
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
textattr(RED); // This method used to set various type kind of text attribute
cprintf("ashoka");
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
textattr(RED+BLINK);
cprintf("ashoka");
getch();
}
Note :- In c++ Use cout<<"your text" in place of cprintf function........
How To set Text BackgroundColor In c and c++
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
textbackground(BLUE);
cprintf("ashoka");
getch();
}
To set Foreground and BackgroundColor Use this............
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
textattr(CYAN);
textbackground(BLUE);
cprintf("ashoka");
getch();
}
Note:--Its mandatory to use textattr before textbackground otherwise it will not work.................
One Of the limitation with turboo c++ is that it supports only limited colors (For more colors use dev c++).to see all those colors which are supported by turboo c++ right click in any color name for ex(RED) in turboo c++ editior......
To Set Font Size in c and c++
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
textmode(C40); //This method used to set font mode
cprintf("ashoka");
getch();
}
In place of C40 try this BW80 and C80................
Its important to know that Different Font Mode and Font Colors Must be written in Capital letters ...
Because they are constant......
and in any programming language Constant are always written in Captial Letters(Naming Convention,To see all about Naming Convention )
Constant----Whose value cannot be changed(Its mandatory that every Constant must hava an int number)..........
#include<conio.h>
void main()
{
clrscr();
textmode(C40);
textattr(CYAN+BLINK);
textbackground(RED);
cprintf("Ashoka\r\nSoni");
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
textmode(C40);
textattr(CYAN+BLINK);
textbackground(RED);
gotoxy(16,12);
cprintf("Ashoka");
gotoxy(17,13);
cprintf("Soni");
getch();
}
Output:
Well I hope you enjoy this tutorial.......
For further detail join me in orkut idiotboyashok@gmail.com
1) Text Mode
2) Graphics Mode
( This Tutorial is all about text Mode)
Its Very easy to set Font ForegroundColor In c,c++.
#include<conio.h>
void main()
{
clrscr();
textattr(RED); // This method used to set various type kind of text attribute
cprintf("ashoka");
getch();
}
To Blink it use this
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
textattr(RED+BLINK);
cprintf("ashoka");
getch();
}
Note :- In c++ Use cout<<"your text" in place of cprintf function........
How To set Text BackgroundColor In c and c++
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
textbackground(BLUE);
cprintf("ashoka");
getch();
}
To set Foreground and BackgroundColor Use this............
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
textattr(CYAN);
textbackground(BLUE);
cprintf("ashoka");
getch();
}
Note:--Its mandatory to use textattr before textbackground otherwise it will not work.................
One Of the limitation with turboo c++ is that it supports only limited colors (For more colors use dev c++).to see all those colors which are supported by turboo c++ right click in any color name for ex(RED) in turboo c++ editior......
To Set Font Size in c and c++
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
textmode(C40); //This method used to set font mode
cprintf("ashoka");
getch();
}
In place of C40 try this BW80 and C80................
Its important to know that Different Font Mode and Font Colors Must be written in Capital letters ...
Because they are constant......
and in any programming language Constant are always written in Captial Letters(Naming Convention,To see all about Naming Convention )
Constant----Whose value cannot be changed(Its mandatory that every Constant must hava an int number)..........
Example 1
#include<stdio.h>#include<conio.h>
void main()
{
clrscr();
textmode(C40);
textattr(CYAN+BLINK);
textbackground(RED);
cprintf("Ashoka\r\nSoni");
getch();
}
Example 2
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
textmode(C40);
textattr(CYAN+BLINK);
textbackground(RED);
gotoxy(16,12);
cprintf("Ashoka");
gotoxy(17,13);
cprintf("Soni");
getch();
}
Output:
| Output |
Well I hope you enjoy this tutorial.......
For further detail join me in orkut idiotboyashok@gmail.com
No comments:
Post a Comment