Skip to content

Commit

Permalink
update 0719
Browse files Browse the repository at this point in the history
  • Loading branch information
WanderedToLa committed Jul 19, 2024
1 parent e6109af commit 23d685b
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 4 deletions.
68 changes: 68 additions & 0 deletions docs/2024/07/07-19.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# 07-19

## 독서

함께자라기와 쏙쏙 들어오는 함수형 코딩 독서시작함
완독부터 해보고 정리하는게 좋을듯함

## cpp pointer

\*(애스터리스크)를 통한 pointer 선언
포인터 타입을 선언할때는 변수의 주소 타입과 일치해야함

```cpp
<type> * <name> = <변수의 주소>

#include<bits/stdc++.h>
using namespace std;

int a = 1;
int main(){
// a의 타입과 일치해야함
int *b = &a;

// 0x16b84b2f0
count << b << '\n';
return 0;
}
```

또한 a의 주소값이 아닌 원래의 변수값을 활용하려면 역참조연산을 통해 원래의 변수값 참조 가능

```cpp
#include<bits/stdc++.h>
using namespace std;

int a = 1;
int main(){
// a의 타입과 일치해야함
int *b = &a;

// 1
count << *b << '\n';
return 0;
}
```

크기가 정해진 배열에서 레퍼런스 연산(&)을 사용하지 않아도 주소값 참조가능

```cpp
#include<bits/stdc++.h>
using namespace std;

int a[3] = {1, 2, 3};
int main(){
// 배열의 첫번째 값 주소
int *c = a;

// c == &a[0]
cout << c << "\n";
cout << &a[0] << '\n';

// c + 1 == &a[1]
cout << c + 1 << '\n';
cout << &a[1] << '\n';

return 0;
}
```
6 changes: 2 additions & 4 deletions src/plugins/blog-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,18 @@ async function createBlogDataPlugin(context, options) {
posts.push({
slug: frontMatter.slug,
title: frontMatter.title,
date: new Date(dateStr), // Date 객체로 변환
date: new Date(dateStr),
});
}
}
}
});

// 날짜를 기준으로 내림차순 정렬 (최신 날짜가 앞으로)
posts.sort((a, b) => b.date - a.date);

// 상위 5개 포스트만 선택하고 날짜를 문자열로 변환
return posts.slice(0, 5).map((post) => ({
...post,
date: post.date.toISOString().split('T')[0], // 'YYYY-MM-DD' 형식으로 변환
date: post.date.toISOString().split('T')[0],
}));
},

Expand Down

0 comments on commit 23d685b

Please sign in to comment.