C语言实现从左向右字幕滚动的效果

#include <stdio.h>
#include <string.h>
#include <windows.h>
 
int main()
{
    char str[100] = "HELLO WORLD! GOOD BYE!";
    int i,j;
	while(1)
	{
		for(i=0;i<strlen(str);i++)
		{
			system("cls");
			for(j=i;j<strlen(str);j++)
			{
				printf("%c",str[j]);
			}
			Sleep(100);
			printf("\n");
		}
	}
    return 0;
}
system("CLS") 是在C语言程序中,调用系统命令cls完成清屏操作。
system("time /t") ;显示时间
system("dir"); //列目录
system("pause");来实现驻留。

system函数是C语言提供的与操作系统衔接的函数,函数原型如下:

#include <stdlib.h> //所在头文件
int system(const char *command); //参数为操作系统命令
函数功能:execute a shell command 执行一个操作系统命令 

  



 

猜你喜欢

转载自www.cnblogs.com/yuanqiangfei/p/11224506.html
今日推荐