목록전체 글 (418)
Creative Code
#include #include #include using namespace std; // 콘솔 창 내의 커서 위치를 x, y 좌표로 이동하는 함수 정의 void gotoxy(int x, int y) { COORD pos = { x, y }; // COORD 구조체를 사용하여 커서 위치를 설정합니다. SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); // 커서 위치를 변경합니다. } int main() { gotoxy(5, 10); // (5, 10) 위치로 커서 이동 cout
#include #include #include using namespace std; int main() { // 각 문자를 출력하고 0.3초씩 쉬는 부분 cout
#include #include #include #include #define LED_1 23 #define LED_2 24 #define SW_1 4 #define SW_2 17 int LED1_flag = 0; int LED2_flag = 0; void sw1_interrupt() { if (LED1_flag == 0) { LED1_flag = 1; } else { LED1_flag = 0; } } void sw2_interrupt() { if (LED2_flag == 0) { LED2_flag = 1; } else { LED2_flag = 0; } } void* thread1_main(void *arg) { while (1) { if (LED1_flag == 0) { digitalWrite(LED_..
#include #include #include #include #include void* thread_main(void *arg); int main(int argc, char *argv[]) { pthread_t t_id; int thread_param=5; void * thr_ret; if(pthread_create(&t_id, NULL, thread_main, (void*)&thread_param)!=0) { puts("pthread_create() error"); return -1; }; if(pthread_join(t_id, &thr_ret)!=0) { puts("pthread_join() error"); return -1; }; printf("Thread return message: %s \n..
#include #include #include void* thread1_main(void *arg) { int i; int cnt = *((int*)arg); for (i = 0; i < cnt; i++) { sleep(1); puts("running thread..1\n"); } return 10; } void* thread2_main(void *arg) { int i; int cnt = *((int*)arg); for (i = 0; i < cnt; i++) { sleep(1); puts("running thread..2\n"); } return NULL; } int main(int argc, char *argv[]) { pthread_t t1_id, t2_id; int thread_param = 5..
#include #include #include // 스레드에서 실행되는 함수 void* thread_main(void *arg) { int i; int cnt = *((int*)arg); for (i = 0; i < cnt; i++) { sleep(1); puts("running thread\n"); // 스레드에서 실행 중인 메시지 출력 } return NULL; } int main(int argc, char *argv[]) { pthread_t t_id; int thread_param = 5; // 스레드 생성 if (pthread_create(&t_id, NULL, thread_main, (void*)&thread_param) != 0) { puts("pthread_create() error\n"..