C/C++ printf 參數說明

本篇列出 C/C++ 常用的 printf 格式化輸出參數與說明,

字元/字串

字元/字串 說明
%c 字元(char)
%s 字元陣列(char *)
%S 寬字元陣列(wchar_t *)

範例如下,

1
2
printf("%c", 'a'); // printf char 字元
printf("%s", "hello"); // printf char * 字元陣列

整數

整數 說明
%d、%i 十進制整數(int)
%u 十進制無號整數(unsigned int)
%ld、%Ld 十進制長整數(long)
%hd 十進制短整數(short)
%x 十六進制
%ld (int64_t => long int linux 64bit)
%lld (int64_t => long int linux 32bit)
%lu (uint64_t => unsigned long int linux 64bit)
%llu (uint64_t => unsigned long int linux 32bit)
%I64d (long long)
%I64u (unsigned long long)
%I64x 64bit的16進制

範例如下,

1
2
3
4
5
int n1 = 0;
printf("%d", n1);

unsigned int n2 = 0;
printf("%u", n2);

浮點數

浮點數 說明
%f 單精度浮點數,預設輸出精度6位(float)

範例如下,

1
2
3
4
5
float n1 = 1.1f;
printf("%f", n1);

double n2 = 1.2;
printf("%f", n2);

其他

其他 說明
%p 指標位址
%% 印出百分比符號

範例如下,

1
2
int n = 0;
printf("%p", &n); // 記憶體位址

參考
https://blog.csdn.net/xiexievv/article/details/6831194
http://edisonx.pixnet.net/blog/post/35305668

其它相關文章推薦
C/C++ 新手入門教學懶人包
32/64bit 作業系統 printf 列印 int64_t/uint64_t 的方法
C++ 計算程式執行時間

消除編譯警告 unused parameter

本篇介紹 GCC 移除 unused parameter 編譯警告的方法,gcc 編譯時開啟 -Wall 會出現很多警告,
如果要解決 unused parameter 這種的警告解決方式有三種,
第一種:去除這個變數
第二種:註解這個變數
第三種:這個變數就是要留著不能註解,使用以下寫法可以閃過編譯器的檢查。

Read More

C++ 類別樣板 class template

本篇介紹 C++ 的 class template,以下為 C++ 使用 class template 範例教學,

c++ template class 簡單版 (class)

c++ class template 類別樣板的範例如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
template<typename T>
class AAA {
public:
AAA(T data) {
mData = data;
}

void print() {
std::cout << mData << endl;
}
private:
T mData;
};

int main() {
AAA<int> a1(10);
a1.print();

AAA<std::string> a2("hello world!");
a2.print();

return 0;
}

Read More

Hexo 熱門主題列表

本篇紀錄 Hexo 的熱門主題,根據 Github 星星數熱門程度與使用體驗選出的精緻 Hexo 主題,排名越後面越熱門,星星數多並不是唯一的考量只是與熱門正相關的數據,
2021/11/09 更新

hexo-theme-landscape (Hexo 預設主題)

A brand new default theme for Hexo.
Github:https://github.com/hexojs/hexo-theme-landscape
星星數:242
Fork數:355

有誰使用該主題:
ShengYu Talk
https://shengyu7697.github.io/

Vexo

Vexo is a Hexo theme inspired by Vue’s official website.
Github:https://github.com/yanm1ng/hexo-theme-vexo
星星數:538
Fork數:121
預覽:點我預覽

Minos

A simple and retro styled Hexo theme, concentrated more on your ideas.
Github:https://github.com/ppoffice/hexo-theme-minos
星星數:623
Fork數:190

有誰使用該主題:
Huli
https://blog.huli.tw/
Askie Lin
https://askie.today/

nexmoe

一个比较特别的 Hexo 主题
Github:https://github.com/theme-nexmoe/hexo-theme-nexmoe
星星數:749
Fork數:113

Diaspora

一款基于WP移植的Hexo主题,适合喜欢摄影,影评,乐评和玩弄文字的你。
Github:https://github.com/Fechin/hexo-theme-diaspora
星星數:966
Fork數:221
預覽:點我預覽
預覽壞了的話可以從 Diaspora 主題原作者WP的主題去看
https://github.com/LoeiFy/Diaspora

Hueman

A redesign of Alx’s wordpress theme Hueman, ported to Hexo.
Github:https://github.com/ppoffice/hexo-theme-hueman
星星數:1.1k
Fork數:338
預覽:點我預覽

有誰使用該主題:
卡斯伯
https://wcc723.github.io/

Melody

A simple & beautiful & fast theme for Hexo.
Github:https://github.com/Molunerfinn/hexo-theme-melody
星星數:1.3k
Fork數:194

Tranquilpeak

A gorgeous responsive theme for Hexo blog framework
Github:https://github.com/LouisBarranqueiro/hexo-theme-tranquilpeak
星星數:1.7k
Fork數:477

Cactus

A responsive, clean and simple theme for Hexo.
Github:https://github.com/probberechts/hexo-theme-cactus
星星數:1.9k
Fork數:555

butterfly

A Hexo Theme: Butterfly
Github:https://github.com/jerryc127/hexo-theme-butterfly
星星數:2k
Fork數:481

Casper

The default theme for Ghost
Github:https://github.com/xzhih/hexo-theme-casper
星星數:133
Fork數:19
預覽:點我預覽
原本 Ghost 的主題
https://github.com/TryGhost/Casper

matery

一个基于材料设计和响应式设计而成的全面、美观的Hexo主题。
Github:https://github.com/blinkfox/hexo-theme-matery
星星數:3.1k
Fork數:831

icarus

A simple, delicate, and modern theme for the static site generator Hexo.
Github:https://github.com/ppoffice/hexo-theme-icarus
星星數:4.4k
Fork數:1.3k
預覽:點我預覽

Yilia

一个简洁优雅的hexo主题
Github:https://github.com/litten/hexo-theme-yilia
星星數:7.9k
Fork數:2.5k

NexT (v6 & v7)

NexT is an elegant and powerful theme
Github:https://github.com/theme-next/hexo-theme-next
星星數:6.5k
Fork數:1.9k

NexT (v5)

Elegant theme for Hexo.
Github:https://github.com/iissnan/hexo-theme-next
星星數:15.5k
Fork數:3.8k
預覽:點我預覽

相關文章
Hexo 使用 Google Analytics 進行網站流量分析
Hexo 本機測試時如何關閉 Google Analytics
Hexo codeblock 插入程式碼區塊與各種程式語言預覽
升級更新 Hexo upgrade
Ubuntu 安裝 Hexo
Mac OS 安裝 Hexo

Hexo 特殊字元問題與解決方式

在 Hexo 中 Markdown 要打`發現沒辦法,後來發現要用一個\反斜線在前就可以了!

另外要打 { 與 } 的話沒辦法像上面用反斜線跳脫字元,結果方式是使用編碼,例如,
{:&#123;
}:&#125;

其他的特殊字元可以參考這篇
Hexo 中 Markdown 特殊字符的处理方法 - SegmentFault 思否
https://segmentfault.com/a/1190000016643268
Hexo 中 Markdown 特殊字符的处理方法_github_38140984的博客-CSDN博客
https://blog.csdn.net/github_38140984/article/details/83005899

Ubuntu 16.04 如何安裝升級 Node.js 8.x

本篇分享 Ubuntu 16.04 如何安裝升級 Node.js 8.x,網路上查了很多 Ubuntu 16.04 安裝方式都過時了~
以下方法我自己試過 OK, 順便來作個紀錄分享,
不要直接 Ubuntu repositories 安裝(apt),那邊的版本很舊。(跟我之前一樣)
指令如下︰

1
2
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

Read More

Hexo 引用站內圖片

本篇紀錄 Hexo 引用站內圖片的語法,

引用站內圖片,無說明文字

1
{% asset_img example.png %}

引用站內圖片,附說明文字

1
{% asset_img example.png This is an example image %}

引用站內圖片,附說明文字, 指定圖片寬度為 640

1
{% asset_img example.png 640 This is an example image %}

Hexo codeblock 插入程式碼區塊與各種程式語言預覽

本篇紀錄在 Hexo 插入程式碼區塊 codeblock 的方法,以及 Hexo 使用的 highlight.js 支援各種程式語言的預覽,

Hexo 插入程式碼區塊 codeblock 的方法

使用方法為兩種
方法一︰
```
程式碼
```

方法二︰

1
2
3
{% codeblock lang:objc %}
程式碼
{% endcodeblock %}

詳細說明如下︰

1
2
3
{% codeblock [title] [lang:language] [url] [link text] %}
code snippet
{% endcodeblock %}

Code Block 在 markdown 中使用可以參考這裡

Read More