본문 바로가기

리눅스에서 getch()함수 사용하기(using getch() in linux) 리눅스에서는 standard library가 glibc에 연동되어 돌아가기 때문에 stdlib을 사용할 수 없다. 따라서 getch()함수도 이용할 수 없는데, 이럴때는 사용자 정의 함수로 만들어서 사용할 수 있다. #include #include int mygetch(void) { struct termios oldt, newt; int ch; tcgetattr( STDIN_FILENO, &oldt ); newt = oldt; newt.c_lflag &= ~( ICANON | ECHO ); tcsetattr( STDIN_FILENO, TCSANOW, &newt ); ch = getchar(); tcsetattr( STDIN_FILENO, TCSANOW, &oldt ); return ch; } 더보기
자바 쓰레드 예제(JAVA Thread example) 간단한 자바 쓰레드 예제입니다. 보통 쓰레드는 run()메소드를 구현합니다. run()메소드 내의 내용이 프로세스 실행고는 독립적으로 실행됩니다. Thread 클래스를 extends해서 사용하는법과 Runnable 인터페이스를 implements해서 사용하는법이 있습니다. 참고로 쓰레드를 사용하면 동기화가 되지 않으므로 쓰레드에 안전하게 동기화를 위해서는 synchronized 키워드를 사용하여 동기화를 시켜줍니다. 1. Theard 클래스를 extends하는법 class SimpleTheard extends Thread { int from,to; public SimpleTheard(int from,int to) { this.from=from; this.to=to; } public void run() {.. 더보기
C# 에서 도스 명령어 실행 System.Diagnostics.Process process = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.FileName = "CMD.exe"; startInfo.WorkingDirectory = @"D:\"; startInfo.UseShellExecute = false; startInfo.RedirectStandardInput = true; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardError = true; process.Ena.. 더보기