Skip to content

Commit e94d205

Browse files
author
hengxin
committed
1-5-c-addendum: +c-library.tex
1 parent 4a31483 commit e94d205

File tree

7 files changed

+245
-8
lines changed

7 files changed

+245
-8
lines changed
256 KB
Binary file not shown.

tutorial/1-5-c-addendum/1-5-c-addendum.tex

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
%%%%%%%%%%
66
\title[\titletext]{\titletext}
7-
\subtitle{--- \subtitletext}
7+
% \subtitle{--- \subtitletext}
88

99
\author[Hengfeng Wei]{\large 魏恒峰}
10-
\titlegraphic{\includegraphics[height = 2.0cm]{figs/qrcode-programming-tutorial.png}}
10+
% \titlegraphic{\includegraphics[height = 2.0cm]{figs/qrcode-programming-tutorial.png}}
1111
\institute{hfwei@nju.edu.cn}
12-
\date{2017年11月10日}
12+
\date{2017年11月24日}
1313

1414
\AtBeginSection[]{
1515
\begin{frame}[noframenumbering, plain]
@@ -22,9 +22,11 @@
2222

2323
\maketitle
2424

25-
\input{parts/josephus} // bit manipulation
26-
\input{parts/horsing}
27-
\input{parts/string}
25+
\input{parts/function-pointer}
26+
\input{parts/c-library}
27+
% \input{parts/josephus} // bit manipulation
28+
% \input{parts/horsing}
29+
% \input{parts/string}
2830

2931
\thankyou{}
3032

105 KB
Loading
118 KB
Loading
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
%%%%%%%%%%%%%%%
2+
\begin{frame}{}
3+
\centerline{\LARGE C Library}
4+
\end{frame}
5+
%%%%%%%%%%%%%%%
6+
7+
%%%%%%%%%%%%%%%
8+
\begin{frame}{}
9+
\fignocaption{width = 0.50\textwidth}{figs/cplusplus-library}
10+
\end{frame}
11+
%%%%%%%%%%%%%%%
12+
13+
%%%%%%%%%%%%%%%
14+
\begin{frame}{}
15+
\fignocaption{width = 0.25\textwidth}{figs/c-library}
16+
\end{frame}
17+
%%%%%%%%%%%%%%%
18+
19+
%%%%%%%%%%%%%%%
20+
\begin{frame}[fragile]{}
21+
\centerline{\large \cyan{(\texttt{\#include <assert.h>})}}
22+
23+
\vspace{0.50cm}
24+
\begin{lstlisting}[style = Cstyle]
25+
|\uncover<2->{\red{\#define NDEBUG}}|
26+
#include <assert.h>
27+
28+
int *vals = malloc(sizeof(int) * n);
29+
assert(vals != NULL)
30+
\end{lstlisting}
31+
\end{frame}
32+
%%%%%%%%%%%%%%%
33+
34+
%%%%%%%%%%%%%%%
35+
\begin{frame}{}
36+
\centerline{\large \cyan{(\texttt{\#include <ctype.h>})}}
37+
38+
\begin{center}
39+
{\large
40+
\texttt{isdigit}\\[0.10cm]
41+
\texttt{isalpha}\\[0.10cm]
42+
\texttt{isalnum}\\[0.40cm]
43+
44+
\texttt{islower}\\[0.10cm]
45+
\texttt{isupper}\\[0.40cm]
46+
47+
\texttt{isspace}\\[0.40cm]
48+
49+
\texttt{tolower}\\[0.10cm]
50+
\texttt{toupper}
51+
}
52+
\end{center}
53+
\end{frame}
54+
%%%%%%%%%%%%%%%
55+
56+
%%%%%%%%%%%%%%%
57+
\begin{frame}{}
58+
\centerline{\large \cyan{(\texttt{\#include <limits.h>})}}
59+
60+
\begin{center}
61+
{\large
62+
\texttt{CHAR\_MIN}\\[0.10cm]
63+
\texttt{CHAR\_MAX}\\[0.40cm]
64+
65+
\texttt{INT\_MIN}\\[0.10cm]
66+
\texttt{INT\_MAX}
67+
}
68+
\end{center}
69+
\end{frame}
70+
%%%%%%%%%%%%%%%
71+
72+
%%%%%%%%%%%%%%%
73+
\begin{frame}{}
74+
\centerline{\large \cyan{(\texttt{\#include <math.h>})}}
75+
76+
\begin{center}
77+
{\large
78+
\texttt{sin}\\[0.10cm]
79+
\texttt{cos}\\[0.40cm]
80+
81+
\texttt{exp}\\[0.10cm]
82+
\texttt{log}\\[0.40cm]
83+
84+
\texttt{pow}\\[0.10cm]
85+
\texttt{sqrt}\\[0.40cm]
86+
87+
\texttt{ceil}\\[0.10cm]
88+
\texttt{floor}\\[0.40cm]
89+
}
90+
\end{center}
91+
\end{frame}
92+
%%%%%%%%%%%%%%%
93+
94+
%%%%%%%%%%%%%%%
95+
\begin{frame}{}
96+
\centerline{\large \cyan{(\texttt{\#include <stdarg.h>})}}
97+
\end{frame}
98+
%%%%%%%%%%%%%%%
99+
100+
%%%%%%%%%%%%%%%
101+
\begin{frame}[fragile]{}
102+
\centerline{\large \cyan{(\texttt{\#include <stddef.h>})}}
103+
104+
\centerline{\large \texttt{size\_t}}
105+
\begin{lstlisting}[style = Cstyle]
106+
sizeof(int)
107+
108+
void* malloc (size_t size);
109+
\end{lstlisting}
110+
111+
\centerline{\large \texttt{NULL}}
112+
\end{frame}
113+
%%%%%%%%%%%%%%%
114+
115+
%%%%%%%%%%%%%%%
116+
\begin{frame}{}
117+
\centerline{\large \cyan{(\texttt{\#include <stdio.h>})}}
118+
119+
\begin{center}
120+
{\large
121+
\texttt{scanf}\\[0.10cm]
122+
\texttt{printf}\\[0.40cm]
123+
124+
\texttt{getchar}\\[0.10cm]
125+
\texttt{putchar}\\[0.40cm]
126+
127+
\texttt{fopen}\\[0.10cm]
128+
\texttt{fclose}\\[0.40cm]
129+
130+
\texttt{EOF}\\[0.10cm]
131+
}
132+
\end{center}
133+
\end{frame}
134+
%%%%%%%%%%%%%%%
135+
136+
%%%%%%%%%%%%%%%
137+
\begin{frame}{}
138+
\centerline{\large \cyan{(\texttt{\#include <stdlib.h>})}}
139+
140+
\begin{center}
141+
{\large
142+
\texttt{atoi}\\[0.10cm]
143+
\texttt{atof}\\[0.40cm]
144+
145+
\texttt{srand}\\[0.10cm]
146+
\texttt{rand}\\[0.40cm]
147+
148+
\texttt{malloc}\\[0.10cm]
149+
\texttt{free}\\[0.40cm]
150+
151+
\texttt{bsearch}\\[0.10cm]
152+
\texttt{qsort}\\[0.40cm]
153+
}
154+
\end{center}
155+
\end{frame}
156+
%%%%%%%%%%%%%%%
157+
158+
%%%%%%%%%%%%%%%
159+
\begin{frame}{}
160+
\centerline{\large \cyan{(\texttt{\#include <string.h>})}}
161+
162+
\begin{center}
163+
{\large
164+
\texttt{strncopy}\\[0.10cm]
165+
\texttt{strncat}\\[0.10cm]
166+
\texttt{strncmp}\\[0.40cm]
167+
168+
\texttt{strlen}\\[0.40cm]
169+
170+
\texttt{strchr}\\[0.10cm]
171+
\texttt{strrchr}\\[0.10cm]
172+
\texttt{strstr}\\[0.40cm]
173+
}
174+
\end{center}
175+
\end{frame}
176+
%%%%%%%%%%%%%%%
177+
178+
%%%%%%%%%%%%%%%
179+
\begin{frame}{}
180+
\centerline{\large \cyan{(\texttt{\#include <time.h>})}}
181+
\end{frame}
182+
%%%%%%%%%%%%%%%
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
%%%%%%%%%%%%%%%
2+
\begin{frame}{}
3+
\centerline{\LARGE Function Pointer}
4+
\end{frame}
5+
%%%%%%%%%%%%%%%
6+
7+
%%%%%%%%%%%%%%%
8+
\begin{frame}[fragile]{}
9+
\centerline{\large \cyan{(\texttt{\#include <stdlib.h>})}}
10+
11+
\vspace{0.30cm}
12+
\begin{lstlisting}[style = Cstyle]
13+
void qsort (void *base, size_t num, size_t size,
14+
int (*compar)(const void*, const void*));
15+
\end{lstlisting}
16+
17+
\pause
18+
\vspace{0.30cm}
19+
\centerline{\large \cyan{(\texttt{compare.c})}}
20+
\end{frame}
21+
%%%%%%%%%%%%%%%
22+
23+
%%%%%%%%%%%%%%%
24+
\begin{frame}[fragile]{}
25+
\begin{lstlisting}[style = Cstyle]
26+
int (*fptr)(int); // fptr is a function pointer
27+
28+
int square(int num) {
29+
return num * num;
30+
}
31+
\end{lstlisting}
32+
33+
\pause
34+
\vspace{0.30cm}
35+
\begin{lstlisting}[style = Cstyle]
36+
int n = 5;
37+
fptr = square; // fptr points to a function
38+
fptr(n);
39+
\end{lstlisting}
40+
\end{frame}
41+
%%%%%%%%%%%%%%%
42+
43+
%%%%%%%%%%%%%%%
44+
\begin{frame}{}
45+
\end{frame}
46+
%%%%%%%%%%%%%%%
47+
48+
%%%%%%%%%%%%%%%
49+
\begin{frame}{}
50+
\end{frame}
51+
%%%%%%%%%%%%%%%

tutorial/1-5-c-addendum/preamble.tex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@
4242
showspaces = false,
4343
showstringspaces = false,
4444
showtabs = false,
45+
escapeinside = ||,
4546
}
4647

4748
% colors
4849
\newcommand{\red}[1]{\textcolor{red}{#1}}
50+
\newcommand{\redoverlay}[2]{\textcolor<#2>{red}{#1}}
4951
\newcommand{\green}[1]{\textcolor{green}{#1}}
5052
\newcommand{\blue}[1]{\textcolor{blue}{#1}}
5153
\newcommand{\cyan}[1]{\textcolor{cyan}{#1}}
@@ -74,8 +76,8 @@
7476
\end{figure}
7577
}
7678

77-
\newcommand{\titletext}{The Josephus Puzzle Revisited}
78-
\newcommand{\subtitletext}{Struct, Linked List, and Function Pointer}
79+
\newcommand{\titletext}{Function Pointer and C Standard Library}
80+
\newcommand{\subtitletext}{}
7981

8082
\newcommand{\thankyou}{
8183
\begin{frame}[noframenumbering]{}

0 commit comments

Comments
 (0)