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
1.9k
よりよいレビュー環境を求めて / A code review odyssey
masawada
0
2.8k
フロントエンドの秩序は保たれているか?
masawada
1
4k
Getting Started with ScratchX
masawada
0
650
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
300
Hack U at UEC 2014.03.27
masawada
0
1.5k
Other Decks in Technology
See All in Technology
pandasはPolarsに性能面で追いつき追い越せるのか
vaaaaanquish
4
4.8k
生成AIと知識グラフの相互利用に基づく文書解析
koujikozaki
1
150
Figma Dev Modeで進化するデザインとエンジニアリングの協働 / figma-with-engineering
cyberagentdevelopers
PRO
1
440
スプリントゴールにチームの状態も設定する背景とその効果 / Team state in sprint goals why and impact
kakehashi
2
110
生成AIとAWS CDKで実現! 自社ブログレビューの効率化
ymae
2
330
Apple/Google/Amazonの決済システムの違いを踏まえた定期購読課金システムの構築 / abema-billing-system
cyberagentdevelopers
PRO
1
220
独自ツール開発でスタジオ撮影をDX!「VLS(Virtual LED Studio)」 / dx-studio-vls
cyberagentdevelopers
PRO
1
180
新R25、乃木坂46 Mobileなどのファンビジネスを支えるマルチテナンシーなプラットフォームの全体像 / cam-multi-cloud
cyberagentdevelopers
PRO
1
130
Amazon_CloudWatch_ログ異常検出_導入ガイド
tsujiba
4
1.6k
MAMを軸とした動画ハンドリングにおけるAI活用前提の整備と次世代ビジョン / abema-ai-mam
cyberagentdevelopers
PRO
1
120
visionOSでの空間表現実装とImmersive Video表示について / ai-immersive-visionos
cyberagentdevelopers
PRO
1
110
VPC間の接続方法を整理してみた #自治体クラウド勉強会
non97
1
920
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.8k
Teambox: Starting and Learning
jrom
132
8.7k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
46
2.1k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
41
2.1k
Building Applications with DynamoDB
mza
90
6.1k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
228
52k
The Art of Programming - Codeland 2020
erikaheidi
51
13k
Rails Girls Zürich Keynote
gr2m
93
13k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
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);
·ͱΊ • ಉ͡ॲཧΛผͷॴͰߦ͍ͬͯΔͱ͖ ؔʹ·ͱΊΔͱݟ௨͕͠Α͘ͳΔ • ฦΓ͕ෳͩͬͨΓɺྻͷ߹ ϙΠϯλΛ͏
·ͱΊ • ϙΠϯλࢀর