cNoteSetWinSize_C语言设置命令窗口大小

 1 #include"stdio.h"
 2 #include"stdlib.h"
 3 #include"windows.h"
 4 //note1<可通过mode 来设置命令窗口大小,其中参数范围lines(1~168),cols(13~9001);命令 mode con cols=9001 lines=168>
 5 //note2<对于调用CMD命令中的参数,可包含在格式化的字符串中,即用sprintf()函数将CMD命令行格式化成字符串传给system()>
 6 //note3<sprintf(char *buffer,"字符串格式",[argument]),buffer是字符串缓冲区,传给system()的地址,[argument]是指参数列表>
 7 //note4<注意头文件:sprintf()[stdio.h] pause[stdlib.h] system()[windows.h]>
 8 //note5<pause会输出“按任意键继续...”的提示,pause>nul 可以实现屏蔽其实的作用;echo 提示 &pause>nul 实现暂停并显示自定义的提示>
 9 /*
10 void winSize(int lines,int cols)
11 自定义命令窗口大小
12 */
13 void winSize(int lines_height,int cols_width)
14 {
15     char cmd[100];
16     if((lines_height<1)||(lines_height>168)||(cols_width<13)||(cols_width>9001))
17     {
18         printf("\nWarnning from winSize(): 1<=lines_height<=168  13<=cols_width<=9001 \n");
19         lines_height=168;
20         cols_width=9001;
21     }
22     sprintf(cmd,"mode con cols=%d lines=%d",lines_height,cols_width);
23     system(cmd);
24 }
25 void main()
26 {
27     system("echo The size of this window will be CHANGED! Press any key ... & pause>nul");
28     winSize(80,40);
29     system("echo The size of this window will RECOVER! Press any key... & pause>nul");
30     winSize(168,9001);
31 }

 

转载于:https://www.cnblogs.com/lzqzldz/p/6298197.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值