C language system function usage

Source: Internet
Author: User

The system () function is used to pass console command lines to the operating system. Taking windows as an example, the result of executing commands through the system () function is the same as that in the DOS window, therefore, all the commands that can be used in the running window can be passed using system (), but note that two slashes must be input, and the C language is used as escape characters.

The system function can call some DOS commands, such as system ("CLS"); // clear the screen, which is equivalent to using the CLS command on DOS and writing the executable file path, you can run it ····

The following lists common DOS commands that can be called using the system function:

Assoc displays or modifies file extension associations.
At is the command and program to be run on the computer.
Attrib displays or changes file attributes.
Set or clear the extended Ctrl + C check.
Cacls displays or modifies the File Access Control List (ACLs ).
Call calls this one from another batch processing program.
CD displays or changes the name of the current directory.
Chcp displays or sets the number of pages of the active code.
Chdir displays or changes the name of the current directory.
Chkdsk checks the disk and displays the status report.
CHKNTFS Displays or modifies the boot time disk check.
CLS clears the screen.
CMD opens another Windows Command Interpreter window.
Color sets the default console foreground and background color.
Comp compares the content 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
Current Drive.
COPY Copies at least one file to another location.
Date: displays or sets the date.
Del deletes at least one file.
DIR Displays files and subdirectories in a directory.
Diskcomp compares two floppy disks.
Diskcopy copies the content of one floppy disk to another.
Doskey: edit the command line, call the Windows Command, and create a macro.
ECHO Displays the message, or explicitly opens or closes the command.
Endlocal ends the localization of Environment Changes in the batch file.
Erase deletes at least one file.
Exit to exit the cmd. exe program (command interpreter ).
FC compares two or two sets of files and displays
Different Places.
Find searches for text strings in the file.
Findstr searches for strings in the file.
For runs a specified command for each file in a set of files.
Format the disk for use with windows.
FTYPE Displays or modifies the file type associated with the file extension.
Goto direct the Windows command interpreter to a batch processing program
Is specified.
Graftabl enables Windows to display images
Extended character set.
Help provides help information for Windows commands.
If executes conditional processing in the batch processing program.
Label to create, change, or delete the volume label of a disk.
MD creates a directory.
Create a directory using mkdir.
Mode: configure the system device.
More: display a result screen at a time.
MOVE Moves the file from one directory to another.
Path: displays or sets the search path for executable files.
PAUSE Suspends processing of batch files and displays messages.
Popd restores the previous value of the current directory saved by pushd.
Print a text file.
Prompt to change the Windows command prompt.
Pushd saves the current directory and changes it.
Rd deletes the directory.
Recover restores readable information from the faulty disk.
Rem record comments in a batch file or config. sys.
Rename the file.
Rename the file.
Replace the file.
Delete the rmdir directory.
Set displays, sets, or deletes Windows environment variables.
Setlocal starts localization of Environment Changes in the batch file.
Shift changes the positions of parameters that can be replaced in a batch file.
Sort classifies input.
Start starts another window to run the specified program or command.
SUBST Associates the path with a drive letter.
Time: displays or sets the system time.
Title: Set the title of the cmd. EXE session.
Tree displays the directory structure of the drive or path in graphic mode.
Type: displays the content of a text file.
Server displays the Windows version.
Verify tells windows whether to verify that the file is correct
Write Data to the disk.
VOL Displays the volume label and serial number of the disk.
Xcopy copies the file and directory tree.

The system function is called by the system. Similar to executing in the CMD window, the parameter is an executable command, such as CLs and notepad.exe.

Eg:

# Include <process. h>

Void main ()

{

System ("Ping 10.10.10.11-T ");

System ("START/B Ping 10.10.10.11-T ");

}

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.