diff --git a/schemes/pointer.tex b/schemes/pointer.tex new file mode 100644 index 0000000..265c4ea --- /dev/null +++ b/schemes/pointer.tex @@ -0,0 +1,44 @@ +\tikzset{every picture/.style={line width=0.75pt}} %set default line width to 0.75pt + +\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1] +%uncomment if require: \path (0,460); %set diagram left start at 0, and has height of 460 + +%Shape: Rectangle [id:dp48909031690071814] +\draw (40,150) -- (199,150) -- (199,220.5) -- (40,220.5) -- cycle ; +%Shape: Rectangle [id:dp3254956575959984] +\draw (222,60) -- (381,60) -- (381,130.5) -- (222,130.5) -- cycle ; +%Shape: Rectangle [id:dp8271767901522998] +\draw (401,151) -- (560,151) -- (560,221.5) -- (401,221.5) -- cycle ; +%Shape: Rectangle [id:dp7663103953587053] +\draw (220,240) -- (379,240) -- (379,310.5) -- (220,310.5) -- cycle ; +%Curve Lines [id:da5551761286150834] +\draw (383,91) .. controls (420.81,62.64) and (422.98,61.51) .. (490.97,150.16) ; +\draw [shift={(492,151.5)}, rotate = 232.52] [color={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.75] (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29) ; +%Curve Lines [id:da7602593545992278] +\draw (490,223) .. controls (553.36,260.13) and (430.5,280.1) .. (382.43,290.2) ; +\draw [shift={(381,290.5)}, rotate = 347.99] [color={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.75] (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29) ; +%Curve Lines [id:da0637330676841148] +\draw (221,279) .. controls (188.16,311.34) and (187.01,308.53) .. (113.12,223.78) ; +\draw [shift={(112,222.5)}, rotate = 408.90999999999997] [color={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.75] (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29) ; +%Curve Lines [id:da9922300811837096] +\draw (121,152) .. controls (86,85.5) and (85,83.5) .. (223,90.5) ; +\draw [shift={(223,90.5)}, rotate = 182.9] [color={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.75] (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29) ; + +% Text Node +\draw (49,155) node [anchor=north west][inner sep=0.75pt] [align=left] {Значение}; +% Text Node +\draw (231,69) node [anchor=north west][inner sep=0.75pt] [align=left] {Переменная \\(идентификатор)}; +% Text Node +\draw (413,162) node [anchor=north west][inner sep=0.75pt] [align=left] {Адрес}; +% Text Node +\draw (236,251) node [anchor=north west][inner sep=0.75pt] [align=left] {Указатель}; +% Text Node +\draw (457,68) node [anchor=north west][inner sep=0.75pt] [align=left] {Хранится по}; +% Text Node +\draw (470,272) node [anchor=north west][inner sep=0.75pt] [align=left] {Сохраняется в}; +% Text Node +\draw (88,66) node [anchor=north west][inner sep=0.75pt] [align=left] {Получается по}; +% Text Node +\draw (65,299) node [anchor=north west][inner sep=0.75pt] [align=left] {Разыменовывается}; + +\end{tikzpicture} diff --git a/sections/04-variables.tex b/sections/04-variables.tex index 2036cb5..359e9ea 100644 --- a/sections/04-variables.tex +++ b/sections/04-variables.tex @@ -72,6 +72,7 @@ integers: 1 $ \end{verbatim} \end{figure} +\label{text:pointers} \paragraph{Тип данных - указатель.} Как было сказано - переменная это именованный контейнер. У каждого такого контейнера есть свой собственный адрес в оперативной памяти. Язык С позволяет узнать этот адрес и работать с ним. Оператор взятия адреса это знак амперсанд (\&), написанный перед именем переменной. То есть у любой переменной всегда есть значение и адрес где это значение хранится. Для вывода в консоль адреса используется специальный заполнитель - \code{\%p}. \begin{figure}[h!]