$30 off During Our Annual Pro Sale. View Details »
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
150
C Lecture 2013.09.19
masawada
September 19, 2013
Tweet
Share
More Decks by masawada
See All by masawada
10年続くサービスのデータを1日未満のメンテナンスウィンドウで安全に移管する
masawada
5
2.1k
よりよいレビュー環境を求めて / A code review odyssey
masawada
0
2.9k
フロントエンドの秩序は保たれているか?
masawada
1
4.1k
Getting Started with ScratchX
masawada
0
670
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
Ruby on Browser - RubyWorld Conference 2024
tmtms
1
110
突き破って学ぶコンテナセキュリティ/container-breakout-cncj-lt
mochizuki875
6
1.1k
深層学習のリペア技術の最新動向と実際 / DNN Repair Techniques for AI Performance Alignment for Safety Requirements
ishikawafyu
0
440
[GDG DevFest Bangkok 2024] - The Future of Retail E-commerce with Gemini AI
punsiriboo
0
300
高品質と高スピードを両立させるソフトウェアQA/Software QA that Supports Agility and Quality
goyoki
8
1.3k
GitHub Actions의 다양한 기능 활용하기 - GitHub Universe '24 Recap
outsider
0
310
ポストモーテムレビューをブレームレスに運営し有効な改善アクションを引き出すために必要だったこと / What is needed to operate postmortem blamelessly and elicit improvement actions
yamaguchitk333
0
190
Devfest_ぼくのかんがえたさいきょうのGoogleプロダクトフォーメーションを本当に導入した話
fukku
0
110
Empowering Customer Decisions with Elasticsearch: From Search to Answer Generation
hinatades
PRO
0
300
AWS re:Invent 2024登壇資料(GBL206-JA: Unleashing the power of generative AI on AWS for your business)
minorun365
PRO
6
210
ARRが3年で10倍になったプロダクト開発とAI活用の軌跡
akiroom
0
230
LangChainとSupabaseを活用して、RAGを実装してみた
atsushii
0
140
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
410
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
Building Adaptive Systems
keathley
38
2.3k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.3k
What's in a price? How to price your products and services
michaelherold
243
12k
Writing Fast Ruby
sferik
627
61k
The Cost Of JavaScript in 2023
addyosmani
45
6.9k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
YesSQL, Process and Tooling at Scale
rocio
169
14k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.3k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
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);
·ͱΊ • ಉ͡ॲཧΛผͷॴͰߦ͍ͬͯΔͱ͖ ؔʹ·ͱΊΔͱݟ௨͕͠Α͘ͳΔ • ฦΓ͕ෳͩͬͨΓɺྻͷ߹ ϙΠϯλΛ͏
·ͱΊ • ϙΠϯλࢀর