아무거나적어~
-
-
[c++] c++ cstype string아무거나적어~ 2023. 1. 10. 23:11
strcpy 는 destination배열의 크기를 고려하지 않으므로 허용되지 않은 메모리를 덮어쓸 수 있음. 쓰지 마셈 strncpy 가 그 대안인데 주의해서 사용할 것. 일어날 수 있는 문제점 source 크기보다 작은 개수만큼 복사할 때 destination에 널문자 복사 안됨 -> 끝에 널문자 추가해주기 destination의 크기가 복사하는 개수보다 작을 때(정확하게는 복사개수 이하일 때) -> 널문자 넣을 공간 없어서 제대로 작동 안함 + 허용되지 않은 메모리 덮어씌우게 됨 결론 destination 의 크기는 다음과 같이 잡는다 복사 문자의 개수 + 1≤ destination의 크기 (1은 널문자 넣기위한 공간) 널문자는 우리가 추가 해주자
-
[c++] The pointer that points to the whole array아무거나적어~ 2023. 1. 10. 16:24
Pointer to an Array | Array Pointer - GeeksforGeeks A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions. www.geeksforgeeks.org 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #include using namespace std; int main() { int arr[5]{}; int* p = arr;..
-
next_permutation implementation아무거나적어~ 2023. 1. 8. 16:33
올바르게 정렬된 가장 오른쪽?의 순서쌍 (a_i, a_j)을 바꾸고 a_i+1 이후의 것들을 reverse std::next_permutation Implementation Explanation I was curious how std:next_permutation was implemented so I extracted the the gnu libstdc++ 4.7 version and sanitized the identifiers and formatting to produce the following demo... #include
-
-
python use custom compare function to heap아무거나적어~ 2023. 1. 7. 15:29
그냥 class 만들어서 < override 하라고 함 Heapq with custom predicate in Python - GeeksforGeeks A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions. www.geeksforgeeks.org
-
python deque은 []로 원소 가져올 수 있음 - 이왜진??아무거나적어~ 2023. 1. 7. 15:02
ㅈㄱㄴ How to peek front of deque without popping? I want to check a condition against the front of a queue before deciding whether or not to pop. How can I achieve this in python with collections.deque? list(my_deque)[0] seems ugly and poor for stackoverflow.com