显示十个字符后暂停程序

时间:2017-09-04 14:38:13

标签: c ascii pause typecasting-operator

我希望能够在显示10个字符的ASCII值后暂停程序并说“继续”或“继续”。 如果有任何用途,我使用Visual Studio 2017。

1 个答案:

答案 0 :(得分:1)

char str[] = "This is my string of text that will be outputted. After every"
             " ten characters, this will be interrupted.\n";

size_t i;
for (i = 0; str[i] != '\0'; ++i) {
    putchar(str[i]);
    if (i % 10 == 0) {
        printf("Press any key to continue . . .\n");
        getchar();
    }
}