본문 바로가기
반응형

[C++]30

C++ 레퍼런스 (&) 분석 코테를 준비하면서 한가지 궁금한 점이 생겨서 메모 #include #include using namespace std; int main() { stack s; s.push({10, 10}); pair top = s.top(); top.second -= 10; cout 2023. 8. 30.
stringstream 실험 아래 출력은 어떻게 될까? #include #include using namespace std; int main() { string str1 = "13 123 13fDfcC 32"; stringstream ss1(str1); int num1; while (ss1 >> num1) cout 2023. 8. 7.
C++과 파이썬의 문자열 파싱 강력한 차이 / 날짜 "2022:04:23" 라는 날짜데이터 day를 2022, 4, 23 이라는 INT형 list 형식으로 파싱해주고 싶을 때 C++에서는 split 함수를 구현해주어야 한다. vector to_format(string day, char delimiter)) { stringstream ss(day); string temp; vector t; while(getline(ss, temp, delimiter)) { int t_v; stringstream x(temp); x >> t_v; t.push_back(t_v); } } int main() { string day = "2022:04:23"; vector li = to_format(day, ':') } 보기만 해도 귀찮아 보인다. 근데 파이썬에서는 정말 간단하게.. 2022. 11. 27.
배열과 벡터의 복사 배열 memmove(destination, source, sizeof(source)); 벡터 copy(source.begin(), source.end(), destionation.begion()); -> 공간 초기화를 하지 않은 채 복사하면 에러가 생긴다. (https://notepad96.tistory.com/48) 그래서 그냥 대입연산자를 사용해도 깊은 복사가 되니까, 대입연산자를 쓴다. #include #include using namespace std; int main() { vector v = {1, 2, 3, 4, 5}; vector b; b = v; b[0] = 2; for(int i = 0 ; i < 5; i++) { cout 2022. 10. 8.
반응형