This example illustrates the joint use of tikz and listings packages. It represents the anatomy of a C function. Compile twice for correct positioning.

Edit and compile if you like:
% Author: Valeria Borodin\documentclass[border={35pt 10pt 150pt 60pt}, % left bottom right topsvgnames]{standalone}\usepackage{tikz}\usetikzlibrary{positioning}\usepackage{listings}\lstset{%frame = tb, % draw frame at top and bottom of code blocktabsize = 1, % tab space widthnumbers = left, % display line numbers on the leftframesep = 3pt, % expand outwardframerule = 0.4pt, % expand outwardcommentstyle = \color{Green}, % comment colorkeywordstyle = \color{blue}, % keyword colorstringstyle = \color{DarkRed}, % string colorbackgroundcolor = \color{WhiteSmoke}, % backgroundcolor colorshowstringspaces = false, % do not mark spaces in strings}\begin{document}\begin{lstlisting}[language = C++, numbers = none, escapechar = !,basicstyle = \ttfamily\bfseries, linewidth = .6\linewidth]int!\tikz[remember picture] \node [] (a) {};!puissance!\tikz[remember picture] \node [] (b) {};!(int x,!\tikz[remember picture] \node [] (c){};!int n) {int i, p = 1; !\tikz[remember picture] \node [] (d){};!for (i = 1; i <= n; i++)p = p * x; !\tikz[remember picture] \node [inner xsep = 40pt] (e){};!return p; !\tikz[remember picture] \node [] (f){};!}\end{lstlisting}\begin{tikzpicture}[remember picture, overlay,every edge/.append style = { ->, thick, >=stealth,DimGray, dashed, line width = 1pt },
Click to download: tikz-listings.tex • tikz-listings.pdf
Open in Overleaf: tikz-listings.tex