Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
C Lecture 2013.09.19
Search
masawada
September 19, 2013
Technology
0
140
C Lecture 2013.09.19
masawada
September 19, 2013
Tweet
Share
More Decks by masawada
See All by masawada
10年続くサービスのデータを1日未満のメンテナンスウィンドウで安全に移管する
masawada
5
2k
よりよいレビュー環境を求めて / A code review odyssey
masawada
0
2.8k
フロントエンドの秩序は保たれているか?
masawada
1
4.1k
Getting Started with ScratchX
masawada
0
660
GyaPC::Asia Tokyo 2015 LT
masawada
0
1.4k
Privileged Apps with Vue.js
masawada
0
160
Chikubeam
masawada
1
1.5k
Git講習 2014.04.15
masawada
1
310
Hack U at UEC 2014.03.27
masawada
0
1.5k
Other Decks in Technology
See All in Technology
VideoMamba: State Space Model for Efficient Video Understanding
chou500
0
280
SRE×AIOpsを始めよう!GuardDutyによるお手軽脅威検出
amixedcolor
1
260
Application Development WG Intro at AppDeveloperCon
salaboy
0
210
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
1k
生成AIが変えるデータ分析の全体像
ishikawa_satoru
0
300
Next.jsとNuxtが混在? iframeでなんとかする!
ypresto
2
1.8k
電話を切らさない技術 電話自動応答サービスを支える フロントエンド
barometrica
2
1.3k
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
13
1.6k
OS 標準のデザインシステムを超えて - より柔軟な Flutter テーマ管理 | FlutterKaigi 2024
ronnnnn
1
370
New Relicを活用したSREの最初のステップ / NRUG OKINAWA VOL.3
isaoshimizu
3
710
コンパウンド戦略に向けた技術選定とリアーキテクチャ
kworkdev
PRO
1
1.8k
SREが投資するAIOps ~ペアーズにおけるLLM for Developerへの取り組み~
takumiogawa
5
1.2k
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Side Projects
sachag
452
42k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
24k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
Documentation Writing (for coders)
carmenintech
65
4.4k
The Cult of Friendly URLs
andyhume
78
6k
Adopting Sorbet at Scale
ufuk
73
9.1k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
730
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
Transcript
ϓϩάϥϛϯάߨश 2013.09.19 by @masawada, @alstamber
Έͳ͞Μ ͓Α͏͍͟͝·͢
ߨࢣ
masawada
alstamber
ΑΖ͓͘͠ئ͍͠·͢
None
ॾ࿈བྷ
• ձ͕12:00·Ͱ͔͑͠·ͤΜ • MMAͷΠϕϯτͰͳ͍ͨΊڭࣨͱΕͣ • ۭ͍ͯͨΒ13:00-15:00͕ͱΕ·͢ • னٳܜΛ12:00-13:00Ͱ͞Έ·͢
• ৯ਆʹ͍͖·͢(ଟ) • ॏཁͳ෦12:00·ͰʹऴΘΒͤ·͢ • 13:00͔ΒΛղ͖·͢ • ͍ΘΏΔԋश • ్தୀࣨՄͰ͢
• શһ͍ͳ͘ͳͬͨΒΊ·͢ • ॾҙ͍Ͱ͢Ͷ • ͜Μͳײ͡ͰਐΊ·͢ • Θ͔Βͳ͍͜ͱ͋ͬͨΒਵ࣭࣌Λ ͱ͍ͯͩ͘͠͞
ߨशͷର
ޙظ͔Β ϓϩάϥϛϯά௨ ͕࢝·Δ
ϓϩάϥϛϯά Α͘Θ͔ΒΜ
͍ͬͯ͏ਓ͚
ܭࢉػ௨ ͱͬͯͳ͍ͻͱ͚
ຊͷత
ޙظͷतۀʹ ͑͏ΔࣝΛ͚ͭΔ
None
ຊͷ͓͠ͳ͕͖ • ϓϩάϥϛϯάͱ • Cͷجૅ • ม • ੍ޚߏจ •
ྻ/ߏମ • ϙΠϯλ • ؔ • ԋश
ϓϩάϥϛϯάͱ
Scratch
͜Ε ϓϩάϥϛϯά
ͻͱͱ͓Γͷཧղ
•ม/ྻ •੍ޚߏจ •ؔ
+ ݴޠಛ༗ͷػೳ
•ϙΠϯλ •ߏମ
ͦͦͳΜͰ CΛษڧ͢Δͷʁ
Rubyͱ͔Pythonͱ͔ φ͍ݴޠΓ͍ͨ
౦େͩͬͯΞϧΰͰ RubyͬͯΔ͡ΌΜ
•×ίϯϐϡʔλΛಈ͔͢ •◦ίϯϐϡʔλΛཧղ͢Δ
None
ܭࢉػͷΈΛ ཧղ͢Δ
ਖ਼ͦ͜·Ͱ ਂ͘Βͳͯ͘Α͍
• ϓϩάϥϛϯάݴޠҰൠͷߟ͑ํ • Cݴޠಛ༗ͷॻ͖ํ • ͱ͔Λ͞ΒͬͱΓ·͢
Cݴޠͷجૅ
•ίʔυΛॻ͘ •ίϯύΠϧ͢Δ •࣮ߦ͢Δ Cݴޠͷجૅ
$ emacs hello.c --- #include <stdio.h> int main() { printf(“Hello,
world!\n”); return 0; }
$ gcc hello.c -o hello $ ./hello Hello, world!
#include <stdio.h> int main() { printf(“Hello, world!\n”); return 0; }
࣮ͳͯ͘ྑ͍
stdio.h = st(andar)d I(n/)O(ut).h(eader)
ඪ४ೖग़ྗ
•printf •scanf
#include <stdio.h> int main() { printf(“Hello, world!\n”); return 0; }
#include <stdio.h> int main() { printf(“Hello, world!\n”); return 0; }
#include <stdio.h> int main() { printf(“Hello, world!\n”); return 0; }
$ gcc hello.c -o hello ɹ
$ [gcc] hello.c -o hello ίϯύΠϧ༻ίϚϯυ
$ gcc [hello.c] -o hello ίϯύΠϧ͢Διʔείʔυ
$ gcc hello.c [-o] hello outfile Φϓγϣϯ
$ gcc hello.c -o [hello] ϑΝΠϧ໊
$ ./hello Hello, World
Ҏ্ɺCͷجૅ
มͷ
ͻͱͱ͓Γͷཧղ
•ม/ྻ •੍ޚߏจ •ؔ
+ ݴޠಛ༗ͷػೳ
•ϙΠϯλ •ߏମ
• ใͷอଘํ๏(σʔλߏ) • ੍ޚ/ؔ
• ใͷอଘ(σʔλߏ) • มɺྻɺ(ϙΠϯλ)ɺߏମ • ੍ޚ/ؔ • ੍ޚߏจɺؔ
ม
x = 10 y = 20
int x = 10; int y = 20;
ܭࢉػ
ON 1 OFF 0
0100101001010100...
None
•int •float, double ුಈখ(খ) •char จࣈ
• ม: 1ͭͷσʔλΛอଘ͢Δͷ • ≒σʔλʹ໊લΛ͚͓ͯ࣋ͬͯ͘ • ܕσʔλͷछྨΛද͢ ·ͱΊ
੍ޚߏจͷ
ϓϩάϥϜ্͔Β ॱ൪ʹॲཧ
ॱ൪Λม͍͑ͨʂ
ൺֱԋࢉࢠ
<ͱ͔>ͱ͔==ͱ͔
ࢄֶ
a b a < b 0 0 0 0 1
1 1 0 0 1 1 0
0ͳΒِ 0Ҏ֎ͳΒਅ
੍ޚߏจ
•if - else - ݅Ͱذ •while - ಉ͡ॲཧΛ·ͱΊΔ •for -
whileͷ্Ґ൛
if - else
͠ʙͳΒ Ͱͳ͚Ε
aͱbͰେ͖͍ํΛ ग़ྗ͍ͨ͠
int a = 10; int b = 20; if (
a < b ) { printf(“%d\n”, b); } else { printf(“%d\n”, a); }
int a = 10; int b = 20; if (
a > b ) { printf(“%d\n”, b); } else { printf(“%d\n”, a); }
while
ʙͷؒ
10͔Β1·Ͱ Χϯτμϯ͍ͨ͠
int i = 10; printf(“%d\n”, i); i = i -
1; printf(“%d\n”, i); i = i - 1; ...
10 9 8 7 6 5 4 3 2 1
i = i - 1;
int i = 10; // i: 10 int tmp =
i - 1; // i: 10 i = tmp; // i: 9
int i = 10; printf(“%d\n”, i); i = i -
1; printf(“%d\n”, i); i = i - 1; ...
int i = 10; while ( 0 < i )
{ printf(“%d\n”, i); i = i - 1; }
for
whileͷ্Ґ൛
int i = 10; while ( 0 < i )
{ printf(“%d\n”, i); i = i - 1; }
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); }
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); }
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); }
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8 7
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8 7
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8 7
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4 3
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4 3
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4 3
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4 3 2
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4 3 2
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4 3 2
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4 3 2 1
int i; for (i = 10; 0 < i; i
= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4 3 2 1
·ͱΊ • ॲཧͷॱ൪Λม͑Δͷʹ੍ޚจΛ͏ • ݅Ͱذ͢Δ • ifͱ͔whileͱ͔͍Ζ͍Ζ͋Δ • forwhileͷ্Ґ൛Έ͍ͨͳײ͡
·ͱΊ • ଞʹdo-whileͱ͔switchͱ͔͋Δ • άάͬͯ(͋Μ·ΓΘͳ͍ؾ͕͢Δ)
None
ྻͷ
ม·ͱΊͨͭ
ม·ͱΊͯ ࣈॱʹͳΒͨͭ
a͞ΜͷମॏΛ ྸॱʹه͍ͨ͠
int a0 = 3; ... int a6 = 22; int
a7 = 24; int a8 = 27;
໊લ͚Δͷ͕ ͱͯΊΜͲ͍͘͞
int a[100]; a[0] = 3; ... a[6] = 22; a[7]
= 24; a[8] = 27;
ศརʂʂʂ
int a[100]; ܕ ྻ໊[ ֬อ͢Δ ]; a[0] = 3; ྻ໊[
ఴࣈ ] = ;
จࣈ char
จࣈྻ char[]
char name[8] = “haru067”;
ཉ͍͠จࣈ+1 Ͱ֬อ
char name[8] = “haru067”;
char name[8] = “haru067\0”;
• ྻΛ͏ͱมΛ·ͱΊΒΕΔ • จࣈྻจࣈܕ(char)ͷྻ ·ͱΊ
ߏମͷ
ߏମ දͷΑ͏ͳͷ
ͪΐͬͱ͚ͩ ྻʹࣅͯΔ
໊લ ྸ ମॏ Ұ 19 165 59 ೋ 20
172 64 ࡾ 21 183 72 ࢛ 16 159 53
struct brother { int age; double height; double weight; };
// ηϛίϩϯΘ͢Εͣʹ
struct brother ichiro; ichiro.age = 19; ichiro.height = 165; ichiro.weight
= 59; printf(“%d\n”, ichiro.age); // 19
struct brother ichiro; ichiro.age = 19; ichiro.height = 165; ichiro.weight
= 59; printf(“%d\n”, ichiro.age); // 19
brother ichiro; ichiro.age = 19; ichiro.height = 165; ichiro.weight =
59; printf(“%d\n”, ichiro.age); // 19
͍͍ͪͪstructॻ͘ͷ ΊΜͲ͏
ܕͷΑ͏ʹѻ͍͍ͨ
struct brother { char name[20]; int age; double height; double
weight; };
typedef struct { char name[20]; int age; double height; double
weight; } brother;
·ͱΊ • ߏମؔ࿈͢ΔσʔλΛ·ͱΊΔ • දΈ͍ͨͳײ͡ • ޙظͷߨٛͰׂͱॏཁͬΆ͍
ؔͷ
None
ؔ
f(x) = x * x
͍͍ͩͨ͋ͬͯΔ
int sq (int num) { return num * num; }
int main(){ int a = 3; printf(“%d\n”, sq(a)); return 0; }
Math: f(x) = x * x C: int sq (int
num) { return num * num; }
Math: f(x) = x * x C: int sq (int
num) { return num * num; }
Math: f(x) = x * x C: int sq (int
num) { return num * num; }
Math: f(x) = x * x C: int sq (int
num) { return num * num; }
Math: f(x) = x * x C: int sq (int
num) { return num * num; }
int sq (int num) { return num * num; }
ܕ ໊ؔ ( ܕ Ҿ ) { ॲཧ ؔͷܕʹ߹ͬͨฦΓ }
int sq (int num) { return num * num; }
ܕ ໊ؔ ( ܕ Ҿ, ܕ Ҿ ) { ॲཧ ؔͷܕʹ߹ͬͨฦΓ }
int sq (int num) { return num * num; }
int main(){ int a = 3; printf(“%d\n”, sq(a)); return 0; }
f(x) = x * x b = 3 f(b) =
9
ҾपΓͰ Ή͜ͱͳ͍
ฦΓ
ϙΠϯλ
None
ϙΠϯλ”ࢀর”
• มͷ”ॴ(ΞυϨε)”ΛೖΕΔม • ม: ࣗൢػͷ্ͷϘλϯ • ϙΠϯλม: ࣗൢػͷԼͷϘλϯ ্ͷϘλϯͷ”ॴ”Λ֮͑Δ ͭ·Γɺ”த”Λ֮͑ΔͷͰͳ͍
ϙΠϯλ
// ϙΠϯλͷએݴ // “ॴ”ΛೖΕΔม int *b_button;
// ϙΠϯλͷએݴ // “ॴ”ΛೖΕΔม int *b_button; b_button = &button; //
&มͷ”ॴ”Λࣔ͢
// ϙΠϯλͷએݴ // “ॴ”ΛೖΕΔม int *b_button; b_button = &button; button
= 1;
// ϙΠϯλͷએݴ // “ॴ”ΛೖΕΔม int *b_button; b_button = &button; button
= 1; printf(“%d\n”, *b_button); // 1
ϙΠϯλ”ࢀর”
ϙΠϯλࢦఆ͞Εͨ ॴͷมͷΛݟʹߦ͘
void sq (int *num1, int *num2) { num1 = &a;
num2 = &b; *num1 = *num1 * *num1; *num2 = *num2 * *num2; } int main(){ int a = 3, b = 6; sq(&a, &b); printf(“%d, %d\”, a, b);
·ͱΊ • ಉ͡ॲཧΛผͷॴͰߦ͍ͬͯΔͱ͖ ؔʹ·ͱΊΔͱݟ௨͕͠Α͘ͳΔ • ฦΓ͕ෳͩͬͨΓɺྻͷ߹ ϙΠϯλΛ͏
·ͱΊ • ϙΠϯλࢀর