HEADER C++
In the process of discussing programming languages, C ++ is one of the types of high-level programming languages. In a programming language there is a header file. This file functions to read or access memory.
The header file is the master file in the C ++ programming language that contains declarations, either in the form of constants, standard input / output, usually this file is in the form of syntax. Usually the header files in the C ++ programming language are used to call libraries in a memory. The file header is a file that is used to define various macro files, functions, variables and constants. Here are some header files that are often used in C ++.
The file header is a file that is used to define various macro files, functions, variables and constants. Here are some header files that are often used in C ++.
Following are the types and functions of file headers::
1.iostream.h
Used to display commands
:
- Cin
Is an input function (used to store data in a variable). General form: cin >> var x;
- Cout
Is an output function (used to display data or writing). General form: cout << "writing"; or cout <- Endl
Used to move lines / enter. General form: cout << "writing" << endl;
-Ends
ends is a manipulator function used to add null characters (ZERO ASCII values) to a row of characters. This function will be useful for sending a number of characters to a file on a disk or modem and ending it with a NULL character.
conio.h
Used to display commands:
- Getch
function to hold the display. General form: getch ();
- Clrscr
function to clean the screen. General form: clrscr;
- Getche
The function is used to read a character with the character that is entered does not need to end by pressing the ENTER button, and the character entered is displayed on the screen.
- Putch
Will display ASCII characters from the x value to the monitor layer without moving the cursor to the next line.
- Clreol
This function is used to clean the screen from the cursor position to the last column, the cursor position does not change.
- Gotoxy
The gotoxy function is used to move the cursor to column x, row y.
- Wherex
The wherex function is used to return the position of the cursor column.
- Wherey
The wherey function is used to return the position of the cursor row.
- Window
The window function is used to define a window based on the upper and lower left coordinates.
Examples of programs that use the iostream.h and conio.h file headers:
#include
#include
Play ()
{
Int z; // defines var z as an integer
Cout << "enter a value:" << endl; // the text that will be displayed. Cin >> z; // enter a value that will be stored in var z
Clrscr; // clear the previous command on the screen
Cout << "the value you entered is:" << z; // displays the contents of var z
getch (); } // is used to hold the display
stdio.h
Used to display commands:
-Printf
Is an output function. General form: printf ("writing");
-Scanf
Is an input function. General form: scanf ("% c", & character);
-Gets
Input function that can read spaces. General form: gets (var x);
Examples of programs that use the stdio.h file header
#include
#include
play ()
{
Int a, t, broad; // variable declaration with integer data type
Printf ("Insert base:"); // displays writing
Scanf ("% i", & a); // save value
Printf ("Enter height:");
Scanf ("% i", & t);
Area = 0.5 * (a * t); // arithmetic formula
Printf ("The area of the triangle is:% i", wide);
getch ();}
4.string.h
-Strcpy
Used to ignore string values.
-Strlen
To find out the length of the string.
-Strupr
Used to make strings into capital.
-Strcmp
Used to compare two strings.
The result of this function is of an integer type with a value: Negative, if the first string is less than the second string. Zero, if the first string is the same as the second string Positive, if the first string is greater than the second string.
General form: strcmp (string1, string2);
-strlwr
Used to change letters to all small. General form: strlwr (string);
-strcat
Used to combine strings. General form: strcat (string1, string2);
Examples of programs that use string.h file headers.
#include
#include
#include
play ()
{
char * name = "learning mathematics"; // makes name var with the contents of "learning mathematics"
char * a; // other var with char data type
cout << "length string:" << strlen (name) << endl; // to calculate string length
cout << strupr (name) << endl; // displays strings in the form of capital
strcpy (a, name); // copy the name var string into var a
cout << a; // displays the string in var a
getch ();}:
5.math.h
Used to display commands:
-Sqrt
Root function
-Pow
Rank function
- Sin (), cos (), tan ()
Each is used to calculate sine, cosine and tangent values from an angle. General form: Sin (angle); Cos (angle); Tan (angle);
-Max
Used to calculate the results of the division and the remainder of the division. General form: max (number1, number2);
-Min
Used to determine the smallest number of two numbers. General form: min (number1, number2).
Examples of programs that use the math.h file header:
#include
#include #include
play ()
{
int value, a, b;
cout << "value:"; cin >> value; // command input value
b = pow (value, 2); // raises the value var with power 2
cout << b << endl; // displays the results of the appointment
a = sqrt (value); // consecrate values
cout << a << endl; // displays root results
getch ();}
6.windows.h
Used to display commands:
-System
Used to give color. The following are examples of programs that use file headers
C ++ programming command windows:
#include
#include
#include
play ()
{
system ("color 27"); // number 2 gives a green background color and number 7 colors the writing white
cout << "Latian"; // displays the words "Exercise" on the screen
getch ();}
7.iomanip.h
Used to display commands:
-Setiosflags ()
Used to set the number of decimal digits behind a comma
Examples of programs that use the iomanip.h file header:
#include
#include
#include
play ()
{
float a, b, c;
cout << "enter the first number:"; cin >> a;
cout << "enter the divider number:"; cin >> b;
c = a / b;
cout << "result:" << setiosflags (ios :: fixed)
<< setprecision (2) << c; // declare the number of decimal digits
getch ();}
8.Stdlib.h
Used to display commands:
-Atof ()
Used to convert string values into double type numbers. General form: atof (char x);
-Atoi ()
Used to change string data types to integers.
-Pow
Used for lifting a number. General form: pow (number, rank).
Examples of programs that use the stdlib.h file header:
#include
#include
#include
#include
play ()
{
char number1 [3]; // var number 1 is char data type
int a1; // var a1 is an integer data type
cout << "Enter Number 1 ="; cin >> number1;
a1 = atoi (number 1); // var number1 with the char data type entered in var a1 which has the type int data
printf ("Number 1 =% s and a1 =% d", number 1, a1);
getch ();}
9.assert.h
Contains confirm macro, used to help detect logical errors and other types of bugs in debugging versions of a program.
10.complex.h
A set of functions to manipulate complex numbers.
11.ctype.h
Defining a set of functions is used to classify characters by their type or to convert between upper and lowercase letters in a way that is independent of those used by character sets (usually ASCII or one of the extensions, although the implementation of using EBCDIC is also known).
12.errno.h
To test the error code reported by the library function.
13.fenv.h
Defines a set of functions to control floating-point environments.
14.float.h
Defining macro constants determines the specific implementation of properties of the floating-point library.
15. inttypes.h
Defines the right type of wide integer.
16.iso646.h
Defining several macros that apply alternative ways to express multiple standard tokens. For programming in ISO 646 sets of character variants.
17.Limits.h
Defining macro constants determines the specific implementation of properties of integer types.
18.Locale.h
Defines the localization function.
19.Setjmp.h
Thus the setjmp and longjmp macros, which are used for non-local exits.
20.Signal.h
Defining the signal handling function.
21.Stdalign.h
To query and determine the alignment of objects.
22.Stdarg.h
To access various numbers of arguments passed to function.
23.stdatomic.h
For atomic operations the data is divided between threads.
24.stdbool.h
Defines Boolean data types.
25.stddef.h
Defines some useful types and macros.
26.stdint.h
Defines the right type of wide integer.
27.stdnoreturn.h
To determine non-return function.
28.tgmath.h
Defines a type of generic-mathematical function.
29.threads.h
Defines a function for managing multiple Threads as well as mutexes and variable conditions.
30.time.h
Defines the function of date and time of handling.
31.Uchar.h
Types and functions for manipulating Unicode characters.
32.Wchar.h
Defining the string handling function is wide.
33.Wctype.h
Defining a set of functions used to classify the characters of their width type or to convert between upper and lower case letters.
actually there are still many explanations in the header c ++ we will discuss it on another page or maybe in another post
We hope for criticism and suggestions from our brothers and sisters. Please give suggestions and criticisms in the comments
No comments:
Post a Comment