본문 바로가기

Study/C C++

(29)
getch() for Linux 구글 신이 있어서 다행이지,, 휴... 모방한번 모방? 모방인가- 한번하는거 힘드네;;; 출처는 http://cboard.cprogramming.com/faq-board/27714-faq-there-getch-conio-equivalent-linux-unix.html #include #include #include int mygetch( ) { 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, TC..
kbhit() for Linux 마찬가지로,, kbhit을 대체할수 있는 방법을 찾다가;; 아직 해보지는 않았는데;;; 궁금하시면 #include stdio.h> #include termios.h> #include unistd.h> #include sys/types.h> #include sys/time.h> /* This id to hide the character we type and suspend any prints after dir 1 , displayed ony when dir 0 */ void changemode ( int dir ) { static struct termios oldt, newt; if ( dir == 1 ) { tcgetattr ( STDIN_FILENO, &oldt ); newt = oldt; newt.c_..
gcc , clrscr gotoxy #include #include void clrscr(void) { int i; for (i = 0; i < 100; i++) // A bunch of new lines for now. It's blank, hey! putchar('\n');} int gotoxy(int x, int y) { char essq[100]; // String variable to hold the escape sequence char xstr[100]; // Strings to hold the x and y coordinates char ystr[100]; // Escape sequences must be built with characters /* ** Convert the screen coordinates to string..
온라인 man 조인시위키 http://www.opengroup.org/onlinepubs/007908799/index.html KLDP 위키 ..지금 다른 컴파일러로 작성된것을 gcc로 모방도중 없는 함수가 있어서 대체할 함수를 찾다가 찾은 온라인 man 페이지;;;
Bool 모랄까..bool을 거의 안써본것 같아요;; 잠깐 검색을 하다가 보통의 C라면, 그냥 bool을 사용하면 안된다고 하더라고요; 이렇게 해서 사용해야 한다고 하더군요;; #include typedef enum {false,true} bool; int main() { bool ask=1; while(ask) { printf("true"); } return 0; } 약간 테스트 한번은 gcc에서 컴파일 해보고 dev-c(gcc 기반이니까 할필요 없었나..) vc++에서도 이렇게 선언을 안하고 쓰면 작동을 안한다는 겁니다- 혹시 그냥 bool을 선언해서 사용하시려고 했다면 만약 안된다면 한번 이렇게 해보세요.; 추가추가 :: 방금전에 gcc를 만지고 있었는데, typedef을 안시켰는데, bool이 됩니다. 제..
C언어, 랜덤함수 , 포인터 랜덤함수, 그냥 rand()만 하면 랜덤 값이 나옵니다. 문제는 프로그램을 다시 시작하면, 이것이 똑같이 나온다는것이 문제랄까 그래서 씨드라는것을 준답니다..; 머리가 안좋은건지 value[5]이걸 포인터로 선언해보려고 하는데;; 안되네요;; 어디선가 int *value 선언하는걸 본것 같은데;; 실행하면 ........대략 이런식로 만들어봤으니까..자바는 포인터가 없다고는 들은것 같은데;; 똑같이 한번 자바로 만들어 봐야하나.;; 추가++09.06.27 PM 2:46 ....malloc이라는것을 모르고 있었습니다.. 이제 이렇게 하니 작동 됩니다!..;;
*** glibc detected *** double free or corruption (top): 0x08d34008 *** *** glibc detected *** double free or corruption (top): 0x08d34008 *** 혹시 gcc에서 이런 오류가 나오나요? 일단 저 같은 경우는 완벽히 사용법도 모르고 하기 때문에. 만약 저처럼 mysql 을 C로 연결시키시는 중이라면 혹시 중간에 mysql_free_result(res)를 사용하셨나 보세요;; 일단 저같은 경우는 이걸 지우니까 바로 없어지네요.
배열초기화 bzero(query,sizeof(query)); memset(query,0,sizeof(query)); 만약 제대로 알고 쓰고 있다면;; ;;만약 저게 초기화가 아니라면;; 난 잘못 알고 있는건가; mysql 만세;