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
データプロダクトの定義からはじめる、データコントラクト駆動なデータ基盤
chanyou0311
2
280
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
150
個人でもIAM Identity Centerを使おう!(アクセス管理編)
ryder472
3
180
Why does continuous profiling matter to developers? #appdevelopercon
salaboy
0
180
Amazon Personalizeのレコメンドシステム構築、実際何するの?〜大体10分で具体的なイメージをつかむ〜
kniino
1
100
OCI Network Firewall 概要
oracle4engineer
PRO
0
4.1k
ノーコードデータ分析ツールで体験する時系列データ分析超入門
negi111111
0
410
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
4
530
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
180
【Startup CTO of the Year 2024 / Audience Award】アセンド取締役CTO 丹羽健
niwatakeru
0
870
いざ、BSC討伐の旅
nikinusu
2
780
Evangelismo técnico: ¿qué, cómo y por qué?
trishagee
0
350
Featured
See All Featured
Embracing the Ebb and Flow
colly
84
4.5k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
Music & Morning Musume
bryan
46
6.2k
Being A Developer After 40
akosma
86
590k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
What's new in Ruby 2.0
geeforr
343
31k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Building an army of robots
kneath
302
43k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Faster Mobile Websites
deanohume
305
30k
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);
·ͱΊ • ಉ͡ॲཧΛผͷॴͰߦ͍ͬͯΔͱ͖ ؔʹ·ͱΊΔͱݟ௨͕͠Α͘ͳΔ • ฦΓ͕ෳͩͬͨΓɺྻͷ߹ ϙΠϯλΛ͏
·ͱΊ • ϙΠϯλࢀর