从两边往中间靠
#define _CRT_SECURE_NO_WARNINGS 1
#include
#include
#include
int main()
{
char arr1[] = "The world is too dangerous";
char arr2[] = " ";
int left = 0;
int right = sizeof(arr1) / sizeof(arr1[0]) - 2;
//-2的原因是因为字符串最后收尾是\0,而这个\0也算一个底数
while (left < right)
{
arr2[left] = arr1[left];
arr2[right] = arr1[right];
printf("%s\n", arr2);
Sleep(1000);
system("cls");
left++;
right--;
}
printf("%s\n", arr2);
return 0;
}
一个一个打出来
#define _CRT_SECURE_NO_WARNINGS 1
#include
#include
#include
int main()
{
char arr1[] = "The world is too dangerous" ;
char arr2[] = " " ;
int zs = sizeof(arr1) / sizeof(arr1[0]);
int left = 0;
int right = zs - 2;
int num1 = sizeof(arr1)-1;
while (left < num1)
{
arr2[left] = arr1[left];
printf("%s\n", arr2);
Sleep(100);
system("cls");
left++;
}
printf("%s\n", arr2);
return 0;
}