Questions on October 18

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.