반응형 Programming/C2 clock(), clock_gettime, timespec_get 1) clock_t start = clock(); clock_t init_time = clock() - start; 2) clock_gettime(CLOCK_MONOTONIC, &start); clock_gettime(CLOCK_MONOTONIC, &end); double time_taken = (end.tv_sec - start.tv_sec) + (end.tv_nsec - start.tv_nsec) / 1000000.0; Q1) What is difference between those two code. The first code block measures the time using the clock function from the time.h library. It measures the time in.. 2023. 2. 9. The malloc function can fail to allocate memory in several cases The malloc function can fail to allocate memory in several cases, including: Insufficient memory: If the system does not have enough memory to allocate the requested block of memory, malloc returns a NULL pointer, indicating that the memory allocation has failed. Out of address space: On some systems, a process has a limited amount of virtual address space. If the malloc function tries to alloca.. 2023. 2. 9. 이전 1 다음 반응형