프로그래밍(2)
-
linux getch 함수
리눅스에는 getch 함수가 없어 여기저기 찾아보다가 발견하게 된 소스 #include int getch(void) { int ch; struct termios buf; struct termios 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; } 위 코드를 getch.h로 만든 후 작성하려는 코드에 #include #include "getch.h" 인클루드 시켜주면 getch 함수를 사용할 수 있음
2019.08.06 -
linux libpcap.h documentation
#define HAVE_REMOTE#include main(){ pcap_if_t *alldevs; pcap_if_t *d; int i=0; char errbuf[PCAP_ERRBUF_SIZE]; /* Retrieve the device list from the local machine */ if (pcap_findalldevs(&alldevs, errbuf) == -1) { fprintf(stderr,"Error in pcap_findalldevs(&alldevs, errbuf: %s\n", errbuf); exit(1); } /* Print the list */ for(d= alldevs; d != NULL; d= d->next) { printf("%d. %s", ++i, d->name); if (d..
2018.04.11