Home Backend Development C#.Net Tutorial What is the c++ clear screen function?

What is the c++ clear screen function?

Jan 18, 2021 pm 05:55 PM
c++ system()

c The screen clearing function is "system("cls")". system() is a C/C function, its function is to issue a DOS command; when the parameter of the function is "cls", it means using the cls command on DOS, and its function is to "clear the screen", that is, to clear all screen display information .

What is the c++ clear screen function?

The operating environment of this tutorial: Windows 7 system, C 17 version, Dell G3 computer.

Related recommendations: C language video tutorial, C video tutorial

c The screen clearing function is "system(" cls")", execute the console command cls, the function is to clear the screen and clear all screen display information.

system is a C/C function. The detailed explanation of the system () function under the Windows operating system is mainly applied in C language. The system function needs to be added with the header file before it can be called.

Function: Issue a DOS command

Usage:int system(char *command);

system function has been included in standard c In the library, you can directly call the

program example:

#include <stdlib.h>
#include <stdio.h>
int main(void)
{
  printf("About to spawn command.com and run a DOS command\n");
  system("dir");
  return 0;
}
Copy after login

Another example: system("pause") can freeze the screen to facilitate observing the execution results of the program; system("CLS") can Implement screen clearing operation. Calling the color function can change the foreground color and background of the console.

The commonly used DOS commands are listed below, all of which can be called with the system function:

  • ASSOC Display or modify file extension associations.

  • AT Commands and programs scheduled to be run on a computer.

  • ATTRIB Display or change file attributes.

  • BREAK Set or clear the extended CTRL C check.

  • CACLS Display or modify the access control lists (ACLs) of files.

  • CALL Call this one from another batch program.

  • CD Display the name of the current directory or change it.

  • CHCP Display or set the number of active code pages.

  • CHDIR Displays the name of the current directory or changes it.

  • CHKDSK Checks the disk and displays a status report.

  • CHKNTFS Display or modify the startup time disk check.

  • CLS Clear the screen.

  • CMD Open another Windows Command Shell window.

  • COLOR Set the default console foreground and background colors.

  • COMP Compares the contents of two or two sets of files.

  • COMPACT Displays or changes the compression of files on NTFS partitions.

  • CONVERT Converts a FAT volume to NTFS. You cannot convert the current drive.

  • COPY Copy at least one file to another location.

  • DATE Display or set the date.

  • DEL Delete at least one file.

  • DIR Displays files and subdirectories in a directory.

  • DISKCOMP Compares the contents of two floppy disks.

  • DISKCOPY Copies the contents of one floppy disk to another floppy disk.

  • DOSKEY Edit the command line, invoke Windows commands and create macros.

  • ECHO Display a message, or turn command echo on or off.

  • ENDLOCAL Ends localization of environment changes in the batch file.

  • ERASE Delete at least one file.

  • EXIT Exit the CMD.EXE program (command interpreter).

  • FC Compare two or two sets of files and display the differences.

  • FIND Search for a text string in a file.

  • FINDSTR Search for a string in a file.

  • FOR Runs a specified command for each file in a set of files

  • FORMAT Format the disk for use with Windows.

  • FTYPE Displays or modifies the file type used for file extension association.

  • GOTO Points the Windows command interpreter to a specified line in the batch program.

  • GRAFTABL Enables Windows to display the extended character set in image mode.

  • HELP Provides help information for Windows commands.

  • IF Execute conditional processing in the batch program.

  • LABEL Create, change or delete the volume label of the disk.

  • MD Create a directory.

  • MKDIR Create a directory.

  • MODE Configure system equipment.

  • MORE Displays one results screen at a time.

  • MOVE Move files from one directory to another.

  • PATH Display or set the search path for executable files.

  • PAUSE Pauses batch file processing and displays a message.

  • POPD Restore the previous value of the current directory saved by PUSHD.

  • PRINT Print text file.

  • PROMPT Change the Windows command prompt.

  • PUSHD Save the current directory and then make changes to it.

  • RD Delete the directory.

  • RECOVER Recovers readable information from problematic disks.

  • REM Record comments in batch files or CONFIG.SYS.

  • REN Rename the file.

  • RENAME Rename the file.

  • REPLACE Replace the file.

  • RMDIR Delete directory.

  • SET Display, set, or delete Windows environment variables.

  • SETLOCAL Starts localization of environment changes in a batch file.

  • SHIFT Change the position of replaceable parameters in the batch file.

  • SORT Classifies the input.

  • START Start another window to run the specified program or command.

  • SUBST Associates a path with a drive letter.

  • TIME Display or set the system time.

  • TITLE Set the window title of the CMD.EXE session.

  • TREE Displays the directory structure of a drive or path in graphical mode.

  • TYPE Display the contents of the text file.

  • VER Displays the Windows version.

  • VERIFY tells Windows whether to verify that the file was correctly written to disk.

  • VOL Display the disk volume label and serial number.

  • XCOPY Copy files and directory trees.

The command can be in both uppercase and lowercase letters.

For more programming related knowledge, please visit: Programming Video! !

The above is the detailed content of What is the c++ clear screen function?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the role of char in C strings What is the role of char in C strings Apr 03, 2025 pm 03:15 PM

In C, the char type is used in strings: 1. Store a single character; 2. Use an array to represent a string and end with a null terminator; 3. Operate through a string operation function; 4. Read or output a string from the keyboard.

Why does an error occur when installing an extension using PECL in a Docker environment? How to solve it? Why does an error occur when installing an extension using PECL in a Docker environment? How to solve it? Apr 01, 2025 pm 03:06 PM

Causes and solutions for errors when using PECL to install extensions in Docker environment When using Docker environment, we often encounter some headaches...

How to calculate c-subscript 3 subscript 5 c-subscript 3 subscript 5 algorithm tutorial How to calculate c-subscript 3 subscript 5 c-subscript 3 subscript 5 algorithm tutorial Apr 03, 2025 pm 10:33 PM

The calculation of C35 is essentially combinatorial mathematics, representing the number of combinations selected from 3 of 5 elements. The calculation formula is C53 = 5! / (3! * 2!), which can be directly calculated by loops to improve efficiency and avoid overflow. In addition, understanding the nature of combinations and mastering efficient calculation methods is crucial to solving many problems in the fields of probability statistics, cryptography, algorithm design, etc.

Four ways to implement multithreading in C language Four ways to implement multithreading in C language Apr 03, 2025 pm 03:00 PM

Multithreading in the language can greatly improve program efficiency. There are four main ways to implement multithreading in C language: Create independent processes: Create multiple independently running processes, each process has its own memory space. Pseudo-multithreading: Create multiple execution streams in a process that share the same memory space and execute alternately. Multi-threaded library: Use multi-threaded libraries such as pthreads to create and manage threads, providing rich thread operation functions. Coroutine: A lightweight multi-threaded implementation that divides tasks into small subtasks and executes them in turn.

distinct function usage distance function c usage tutorial distinct function usage distance function c usage tutorial Apr 03, 2025 pm 10:27 PM

std::unique removes adjacent duplicate elements in the container and moves them to the end, returning an iterator pointing to the first duplicate element. std::distance calculates the distance between two iterators, that is, the number of elements they point to. These two functions are useful for optimizing code and improving efficiency, but there are also some pitfalls to be paid attention to, such as: std::unique only deals with adjacent duplicate elements. std::distance is less efficient when dealing with non-random access iterators. By mastering these features and best practices, you can fully utilize the power of these two functions.

How to apply snake nomenclature in C language? How to apply snake nomenclature in C language? Apr 03, 2025 pm 01:03 PM

In C language, snake nomenclature is a coding style convention, which uses underscores to connect multiple words to form variable names or function names to enhance readability. Although it won't affect compilation and operation, lengthy naming, IDE support issues, and historical baggage need to be considered.

Usage of releasesemaphore in C Usage of releasesemaphore in C Apr 04, 2025 am 07:54 AM

The release_semaphore function in C is used to release the obtained semaphore so that other threads or processes can access shared resources. It increases the semaphore count by 1, allowing the blocking thread to continue execution.

Issues with Dev-C version Issues with Dev-C version Apr 03, 2025 pm 07:33 PM

Dev-C 4.9.9.2 Compilation Errors and Solutions When compiling programs in Windows 11 system using Dev-C 4.9.9.2, the compiler record pane may display the following error message: gcc.exe:internalerror:aborted(programcollect2)pleasesubmitafullbugreport.seeforinstructions. Although the final "compilation is successful", the actual program cannot run and an error message "original code archive cannot be compiled" pops up. This is usually because the linker collects

See all articles