#include <stdio.h>
#include <termio.h>
int getch(void)
{
int ch;
struct termios buf, save;
tcgetattr(0, &save);
buf = save;
buf.c_lflag &= ~(ICANON|ECHO);
buf.c_cc[VMIN] = 1;
buf.c_cc[VTIME] = 0;
tcsetattr(0, TCSAFLUSH, &buf);
ch = getchar();
tcsetattr(0, TCSAFLUSH, &save);
return ch;
}
'소공 in KIT/Study'에 해당되는 글 19건
-
[C/C++] Unix/Linux 에서 getch() 구현
2009/04/16
-
[C/C++] 콘솔 달력 프로그램
2009/04/15
-
[Tip] glut 3.7 Visual Studio 2005에서 사용하기
2009/04/09
-
[Tip] Visual Studio 2005 (C++)에서 Speech SDK 5.1 사용하기
2009/04/02
-
[Win32API] DrawText() 사용법
2008/10/27
-
[C/C++] 이미지(.raw) 파일 입출력
2008/10/16
-
[C/C++/JAVA] 2차원배열 동적할당/해제
2008/10/07
-
[Win32API] InvalidateRect()
2008/10/04
-
[Win32API] 기본 템플릿(WinCE) - MessageMap Ver.
2008/10/02
-
[Win32API] 기본 템플릿
2008/09/25
[C/C++] Unix/Linux 에서 getch() 구현
2009/04/16 11:41[C/C++] 콘솔 달력 프로그램
2009/04/15 00:20**초심플 기능**
하나. 현재 날짜의 달력을 출력해준다.
하나. 이전달/다음달 이동 기능이 있다.

// 달력 구조체
typedef struct tagCalendar {
int year;
int month;
int first_day_of_week;
int days;
} CALENDAR;** 주요함수명세 **
// 해당 연월의 달력을 얻어오는 함수
CALENDAR get_calendar(int year, int month);
// 해당 월의 1일의 요일을 얻어오는 함수
DAY_OF_WEEK get_first_day_of_week(int year, int month);
// 해당 월의 총 일수를 얻어오는 함수
int get_day_of_month(int year, int month);
// 달력을 출력하는 함수
void display_calendar(CALENDAR cal);
[Tip] glut 3.7 Visual Studio 2005에서 사용하기
2009/04/09 12:40The OpenGL Utility Toolkit(glut) 3.7 Visual Studio 2005에서 사용하기
0. glut를 다운 받는다.
1. glut.h 파일을 C:\Program Files\Microsoft Visual Studio 8\VC\include\gl 폴더에 복사
2. glut32.lib 파일을 C:\Program Files\Microsoft Visual Studio 8\VC\lib 폴더에 복사
3. glut.dll; glut32.dll 파일을 C:\WINDOWS\system32 폴더에 복사
* glut 사이트
http://www.opengl.org/resources/libraries/glut/ (새 창으로 열기)
http://www.xmission.com/~nate/glut.html (새 창으로 열기)
* glut 3.7.6 library for Win32 다운로드
http://www.xmission.com/~nate/glut/glut-3.7.6-bin.zip (새 창으로 열기)
*glut 3.7 source code for Win32 다운로드
http://www.opengl.org/resources/libraries/glut/glut37.zip (새 창으로 열기)
[Tip] Visual Studio 2005 (C++)에서 Speech SDK 5.1 사용하기
2009/04/02 11:32Microsoft 사에서 제공하는 Speech SDK 5.1을 다운 받아 설치한다.
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=5e86ec97-40a7-453f-b0ee-6583171b4530 (새 창으로 열기)

Visual Studio 2005에서 프로젝트에 Speech 라이브러리를 사용하기 위해선 아래와 같은 과정을 거친다.
1. 새로운 프로젝트를 만들고 프로젝트 > 속성 메뉴를 연다.
2. 구성속성 > C/C++ > 일반 탭에서 "추가포함 디렉토리"에 Speech SDK가 설치된 경로에서 include를 지정해준다.

3. 구성속성 > 링커 > 일반 탭에서 "추가 라이브러리 디렉터리"는 다음과 같이 지정해 준다.

4. 마지막으로 구성속성 > 링커 > 입력 탭에서 "추가 종속성" 부분에 필요한 라이브러리 파일을 추가해주면 된다.

아래 코드는 아주 간단한 TTS(Text.To.Speech) 예제 소스이다.
Win32 콘솔용 프로젝트를 생성했기 때문에 시작되면서 콘솔창이 하나 뜨고, 스피커를 통하여 "Hello world! This is simple Text-to-Speech example."이라고 읽어준다.
#define _ATL_APARTMENT_THREADED
#include <atlbase.h>
//You may derive a class from CComModule and use it if you want to override something,
//but do not change the name of _Module
extern CComModule _Module;
#include <atlcom.h>
#include <sapi.h>
int main(int argc, char* argv[])
{
ISpVoice * pVoice = NULL;
if (FAILED(::CoInitialize(NULL)))
return FALSE;
HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
if( SUCCEEDED( hr ) )
{
hr = pVoice->Speak(L"Hello world! This is simple TTS example.", 0, NULL);
pVoice->Release();
pVoice = NULL;
}
::CoUninitialize();
return TRUE;
}
[Win32API] DrawText() 사용법
2008/10/27 21:19int DrawText (HDC hdc, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat);
- hdc : 텍스트를 출력할 DC의 핸들
- lpString : 출력할 문자열
- nCount : 출력할 문자열의 길이, 값을 -1로 주면 자동으로 lpStrig 문자열의 크기만큼 출력
- uFormat : 출력할 때의 정렬 방법
:: uFormat 값 ::
- DT_LEFT : 좌측 정렬
- DT_VCENTER : 중앙 정렬
- DT_NOCLIP : 줄 넘김을 하지 않음
- DT_CALCRECT : 텍스트는 출력되지 않고, 문자열이 출력될 사각형의 폭과 높이를 계산하여 lpRect를 통하여 넘겨 줌
// 문자열을 출력하지 않고 폭과 높이를 계산하여 rect에 저장.
DrawText (hdc, TEXT("Hello Friends"), -1, &rect,
DT_CALCRECT | DT_CENTER | DT_SINGLELINE);
// 문자열 출력
DrawText (hdc, TEXT("Hello Friends"), -1, &rect,
DT_CENTER | DT_SINGLELINE);


