调用系统计算器n次

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>

void main1(){
	int num;
	printf("times:");
	scanf("%d", &num); 
	char str[40];
	sprintf(str,"for /l %%i in (1,1,%d) do start calc",num);
	system(str);
	
	//system("pause");
}

void main(){
	
	printf("% \n");  //output: null
	printf("%%  \n"); //output:%  字符串要用"%%" ,字符只要'%'
	printf("%%i \n");// output:%i 
	printf("======\n");
	char str[40]; //定义了一个字符数组,每一个都是一个字符
	sprintf(str,"%%i");
	//数组里面是按照字符一个一个出来的,打印第一个%时为空,第二%个也为空,第三个i,由于未初始化,则默认为0
	//这是显示的bug, 不影响system的调用执行
	printf(str);

	getchar();
}

猜你喜欢

转载自www.cnblogs.com/luoxuw/p/11222756.html