1. What is the role of header file <cstring>?
(1) puts function:
The output (equivalent to cout<<) is of little use.
(2) Gets function:
The cin>> used for input (equivalent to the upgraded version) is more useful.
(3) strcpy function:
Used to copy a string into another variable.
Basic usage:
strcpy (STR1,STR2); // Copy the second variable into the first variable, which is str2 copy to St1
(4) strcmp function:
Used to compare the size of a string:
if (strcmp (STR1,STR2) >0) { }// in an English dictionary, such as: B>a,a>a.
(5) strlen function:
It is useful to get the length of a string.
strlen (a); // gets the length of the variable a
(6) STRLWR function:
Uppercase to lowercase for letters, and ASCII + 32来 can also be implemented.
STRLWR (a); // converts uppercase in string A to lowercase
(7) STRUPR function:
Lowercase capitalization for letters can also be implemented using ASCII code-32来.
STRUPR (a); // converts lowercase in string A to uppercase
(8) strcat function:
Connection functions for strings:
str1[]={i}strcat (STR1,STR2); // add str2 to the end of STR1 (str1 space is large enough)
2. How to program the use of "WASD" to control the computer interface (up and down to move around)
The teacher replied: The problem is very good, and so on after learning the hands ~ ~
3. How to adjust the color of individual fonts, for example:
#include <iostream>#include<windows.h>using namespacestd;intMain () {Setconsoletextattribute (GetStdHandle (std_output_handle), foreground_intensity|foreground_red); cout<<"Hello"<<endl;//output in C + + with using namespace std; # include <iostream>Setconsoletextattribute (GetStdHandle (std_output_handle), foreground_intensity |foreground_red| Foreground_green |foreground_blue); cout<<" World"<<Endl; Setconsoletextattribute (GetStdHandle (std_output_handle), foreground_intensity|Foreground_green|foreground_blue); cout<<" World"<<Endl; return 0;}
Questions on October 18