① c语言中system("pause")是什么作用和意思
暂停执行,按任意键继续,一般需要把执行过程中的执行信息打印出来时就可以加这么一条,方便查看执行结果。
② C语言里的system函数都有什么用
system(const
char
*
string);
执行括号里的字符串命令。
具体的你可以网络,里面有windows和linux下的这个函数的介绍。
讲个实例,源码如下
#include
<stdio.h>
#include
<string.h>//strcat的头文件
#include<stdlib.h>//system的头文件
int
main()
{
char
cmds[5]={0};
strcat(cmds,"calc");
system(cmds);
return
0;
}
程序运行结构就是调用system函数,将参数执行dos命令
,最终出现windows的计算器
③ C语言中system("dos cmd");的用法
system函数的功能就是调用系统命令,对于windows来说,就是调用dos命令,也就是dos
cmd。
要使用system函数,需要引用stdlib.h,即
#include
<stdlib.h>
调用时,参数为字符串形式,可以是变量,也可以是常量。
比如
system("pause");
就是相当于调用pause命令,使运行暂停,直到按任意键继续。
④ 在C语言中,程序有一个是system("CLS");时什么意思
在C语言程序中是清屏的意思。
当你编写的程序有输出的时候,如果要进行多次调试,屏幕上会显示很多次的输出的结果,看上去非常的复杂非常的乱。那么我们就可以在程序中的输出语句之前加上“system("CLS");”,当我们用上这条语句之后。
这样每次程序运行的时候都会将上一次运行输出的内容给清除掉,屏幕上只显示本次输出的结果。这样看起来就非常的简洁。
(4)c语言调用system扩展阅读:
在VC环境下有两种办法实现清屏:
1、#include <windows.h>
system("cls");这种办法的缺点是程序额外运行系统程序执行清屏操作,延长了程序执行时间。
2、自己写函数,这种办法快
这是从微软MSDN得到的方法:
/* Standard error macro for reporting API errors */
#define PERR(bSuccess, api){if(!(bSuccess)) printf("%s:Error %d from %s
on line %d ", __FILE__, GetLastError(), api, __LINE__);}
void cls( HANDLE hConsole )
{
COORD coordScreen = { 0, 0 }; /* here's where we'll home the
cursor */
BOOL bSuccess;
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */
DWORD dwConSize; /* number of character cells in
the current buffer */
/* get the number of character cells in the current buffer */
bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
PERR( bSuccess, "GetConsoleScreenBufferInfo" );
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
/* fill the entire screen with blanks */
bSuccess = FillConsoleOutputCharacter( hConsole, (TCHAR) ' ',
dwConSize, coordScreen, &cCharsWritten );
PERR( bSuccess, "FillConsoleOutputCharacter" );
/* get the current text attribute */
bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
PERR( bSuccess, "ConsoleScreenBufferInfo" );
/* now set the buffer's attributes accordingly */
bSuccess = FillConsoleOutputAttribute( hConsole, csbi.wAttributes,
dwConSize, coordScreen, &cCharsWritten );
PERR( bSuccess, "FillConsoleOutputAttribute" );
/* put the cursor at (0, 0) */
bSuccess =SetConsoleCursorPosition( hConsole, coordScreen );
PERR( bSuccess, "SetConsoleCursorPosition" );
return;
}
参考资料来源:网络-system("cls")
⑤ 在c语言中system有什么功能,如何使用
可以调用
系统命令
,如system("pause"),可以使
程序暂停
,保持窗口显示,否则程序就立刻退出了
⑥ C语言中system("pause")是什么作用和意思
system(“pause”) 是调用DOS系统的暂停命令 pause 来暂停程序执行,按任意一个键后将继续执行。
Sleep() 是 windows 的 函数,让程序进入睡眠状态,要求参数 时间毫秒,到时间后自动苏醒,程序继续执行。
例如: Sleep(2500); 休眠 2.5 秒,满2.5 秒 后 程序继续运行。
⑦ 怎样调用C语言的system函数
#include<stdio.h>就可以了
system函数中
输入值都是系统命令了,比如
system("pause");
system("start
xxx.exe");等等
需要什么功能
再在网上查询
⑧ C语言的system函数
system(系统)函数
windows操作系统下system () 函数详解(主要是在C语言中的应用)
功 能: 发出一个DOS命令
用 法: int system(char *command);
system函数已经被收录在标准c库中,可以直接调用
程序例:
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
printf("About to spawn and run a DOS command\n");
system("dir");
return 0;
}
又如:system("pause")可以实现冻结屏幕,便于观察程序的执行结果;system("CLS")可以实现清屏操作。而调用color函数可以改变控制台的前景色和背景,具体参数在下面说明。
例如,用 system("color 0A"); 其中color后面的0是背景色代号,A是前景色代号。各颜色代码如下:
0=黑色 1=蓝色 2=绿色 3=湖蓝色 4=红色 5=紫色 6=黄色 7=白色 8=灰色 9=淡蓝色 A=淡绿色 B=淡浅绿色 C=淡红色 D=淡紫色 E=淡黄色 F=亮白色
(注意:Microsoft Visual C++6.0 支持system)
举例
看了下面实例,相信你会对学到更多system在C程序设计中的应用。
例一:
C语言调用DOS命令实现定时关机:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int print()
{
printf(" ╪╪╪╪╪╪╧╧╧╧╧╧╧╧╪╪╪╪╪╪\n");
printf("╔═══╧╧C语言关机程序 ╧╧═══╗\n");
printf("║※1.实现10分钟内的定时关闭计算机 ║\n");
printf("║※2.立即关闭计算机 ║\n");
printf("║※3.注销计算机 ║\n");
printf("║※0.退出系统 ║\n");
printf("╚═══════════════════╝\n");
return 0;
}
void main()
{
system("title C语言关机程序");//设置cmd窗口标题
system("mode con cols=48 lines=25");//窗口宽度高度
system("color 0B");
system("date /T");
system("TIME /T");
char cmd[20]="shutdown -s -t ";
char t[5]="0";
print();
int c;
scanf("%d",&c);
getchar();
switch(c)
{
case 1:printf("您想在多少秒后自动关闭计算机?(0~600)\n");scanf("%s",t);system(strcat(cmd,t));break;
case 2:system("shutdown -p");break;
case 3:system("shutdown -l");break;
case 0:break;
default:printf("Error!\n");
}
system("pause");
exit(0);
}
例二:
用C语言删除文件,例如文件的位置是d:\123.txt
用system()函数执行windows命令。
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
system("del d:\\123.txt");
return 0;
}
⑨ 在c语言中system有什么功能,如何使用
可以调用系统命令,如system("pause"),可以使程序暂停,保持窗口显示,否则程序就立刻退出了