0

次の簡単なコードを c で記述し、バッチ ファイルで入力リダイレクトを使用しました。while ループ内でプログラムを一時停止するにはどうすればよいですか?

#include <stdio.h>

int main(void) 
{
  char buffer[2048];

    while ( !feof(stdin) ) {
    gets( buffer );
    printf( "%s", buffer );
    //I want to pause the program here, until i press enter
    }
  return 0;
}

バッチ ファイルは次のとおりです。 main.exe < input.txt >output.txt


前もって感謝します!

4

1 に答える 1

0
#include <stdio.h>
#include <conio.h>

int main(void){
    char buffer[2048];

    while ( !feof(stdin) ) {
        gets( buffer );
        printf("%s", buffer );
        while(!_kbhit());
        _putch('\n');
        while(_kbhit())
            _getch();
    }
    return 0;
}
于 2013-05-14T11:34:52.353 に答える