显示输出时编译器自动关闭

时间:2015-01-29 22:54:31

标签: c visual-studio-2013

我想输入值然后显示我输入的值,但是在输入值之后,它会在自动关闭之前显示输出半秒。

这是我的代码

    #include<stdio.h>
int main()
{
    float startnummer;
    float hoppnummer;
    float svarighetsgrad;
    float domarpoang1;
    float domarpoang2;
    float domarpoang3;
    float domarpoang4;
    float domarpoang5;
    float domarpoang6;
    float domarpoang7;

    printf("Startnummer: \n");
    scanf_s("%f", &startnummer );

    printf("Hoppnummer:\n");
    scanf_s("%f", &hoppnummer);

    printf("Svarighetsgrad:\n");
    scanf_s("%f", &svarighetsgrad);

    printf("Domarpoang 1:\n");
    scanf_s("%f", &domarpoang1);

    printf("Domarpoang 2:\n");
    scanf_s("%f", &domarpoang2);

    printf("Domarpoang 3:\n");
    scanf_s("%f", &domarpoang3);

    printf("Domarpoang 4:\n");
    scanf_s("%f", &domarpoang4);

    printf("Domarpoang 5:\n");
    scanf_s("%f", &domarpoang5);

    printf("Domarpoang 6:\n");
    scanf_s("%f", &domarpoang6);

    printf("Domarpoang 7:\n");
    scanf_s("%f", &domarpoang7);

    printf("Startnummer: %f \n", startnummer);
    printf("Hoppnummer:\n", hoppnummer);
    printf("Svarighetsgrad:\n", svarighetsgrad);
    printf("Domarpoang 1:\n", domarpoang1);
    printf("Domarpoang 2:\n", domarpoang2);
    printf("Domarpoang 3:\n", domarpoang3);
    printf("Domarpoang 4:\n", domarpoang4);
    printf("Domarpoang 5:\n", domarpoang5);
    printf("Domarpoang 6:\n", domarpoang6);
    printf("Domarpoang 7:\n", domarpoang7);

    printf("Hoppoang: \n");

    printf("Tryck tangent for nytt hopp!");
    getchar();
    return 0;
}

是否有人知道如何制作它以便在显示输出时不会自动关闭? 感谢

1 个答案:

答案 0 :(得分:0)

如果在 stdin 中缓冲了任何字符,

getchar()将无效。 如果您使用的是Visual Studio,请按 Ctrl + F5 执行该程序。这将使窗口保持打开状态,等待按键退出。