【问题标题】:How to implement a “loading screen”?如何实现“加载屏幕”?
【发布时间】:2021-06-26 11:27:04
【问题描述】:

有没有办法调用loading_screen()然后在三秒后清屏然后进入程序??

#include <stdio.h>
    
    void loading_screen() {
        printf("\n*\t *\t *\t *\t *\t *\t *\t *\n* Welcome to your blah blah! *\n*\t *\t *\t *\t *\t *\t *\t *\n\n");
    }
    
    void starting_screen() {
        printf("1. add new recipe\n");
        printf("2. search for recipe\n");
        printf("3. delete recipe\n");
    }
    
    int main(int argc, char *argv[]) {
        loading_screen();
        starting_screen();
        return 0;
    }

【问题讨论】:

  • 你的平台是什么?
  • 你想让它看起来像一个“真正的”程序吗? “真正的”程序是如此之快,他们不需要加载屏幕!

标签: c function main time.h


【解决方案1】:

您可以在 windows 上使用 system("cls"); 或在 linux 上使用 system("clear");

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
    
    void loading_screen() {
        printf("\n*\t *\t *\t *\t *\t *\t *\t *\n* Welcome to your blah blah! *\n*\t *\t *\t *\t *\t *\t *\t *\n\n");
    }
    
    void starting_screen() {
        printf("1. add new recipe\n");
        printf("2. search for recipe\n");
        printf("3. delete recipe\n");
    }
    
    int main(int argc, char *argv[]) {
        loading_screen();
        sleep(3);
        system("cls");//system("clear");
        starting_screen();
        return 0;
    }

【讨论】:

    猜你喜欢
    • 2020-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-19
    • 2015-06-21
    相关资源
    最近更新 更多