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 執行一個操作系統命令 

  



 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM