#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
int main()
{
char arr1[] = "Welcome to your world!!!";
char arr2[] = "************************";
int left = 0;
int right = sizeof(arr1) - 1;
while (left <= right)
{
arr2[left] = arr1[left];
arr2[right] = arr1[right];
printf("%s\n", arr2);//将arr1从两端开始逐个赋给arr2,输出arr2
Sleep(100);
system("cls");
left++;
right--;
}
printf("%s\n", arr2);
return 0;
}
代码目的:逐渐显示Welcome to your world!!!
写这篇文章的目的:方便回忆Sleep和system两个函数的用法
重点:需要使用到Sleep()和system()两个函数
Sleep()函数
单位:ms
实例:
Sleep(1000);//sleep for 1 second
头文件:
#include <windows.h>
system()函数
system("cls");//清屏