<commit_before>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% Pointers %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\pointedsl{
	Pointers
}
\end{frame}

%
% Content:
% 1. Passing by value
% 2. Passing pointers
% 3. Passing by reference
% 4. Pointer arithmetic

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
\frametitle{Passing by value}
\begin{lstlisting}
void swap_wrong(int x, int y){
    int tmp = x;
    x = y;
    y = tmp;
}
int a = 1, b = 2;
swap_wrong(a, b);
// did not work! a=1, b=2
\end{lstlisting}
\misc{
	Function arguments are \textbf{passed by value} (copy of value). We need pointers to modify \ctext{a} and \ctext{b} in the code above.
}
\end{frame}

\begin{frame}[fragile]
\frametitle{Using pointers}
\begin{lstlisting}
void swap_ptr(int *x, int *y){
    int tmp = *x;
    *x = *y;
    *y = tmp;
}
int a = 1, b = 2;
swap_ptr(&a, &b);
// now a=2, b=1
\end{lstlisting}
\misc{
	\ctext{\&a} uses the \textbf{reference} operator to get the adresse of \ctext{a}.
	
	\ctext{*x} uses the \textbf{dereference} operator to get / set the value at the adress given by \ctext{x}.
}
\end{frame}<commit_msg>Address typo<commit_after>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% Pointers %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\pointedsl{
	Pointers
}
\end{frame}

%
% Content:
% 1. Passing by value
% 2. Passing pointers
% 3. Passing by reference
% 4. Pointer arithmetic

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
\frametitle{Passing by value}
\begin{lstlisting}
void swap_wrong(int x, int y){
    int tmp = x;
    x = y;
    y = tmp;
}
int a = 1, b = 2;
swap_wrong(a, b);
// did not work! a=1, b=2
\end{lstlisting}
\misc{
	Function arguments are \textbf{passed by value} (copy of value). We need pointers to modify \ctext{a} and \ctext{b} in the code above.
}
\end{frame}

\begin{frame}[fragile]
\frametitle{Using pointers}
\begin{lstlisting}
void swap_ptr(int *x, int *y){
    int tmp = *x;
    *x = *y;
    *y = tmp;
}
int a = 1, b = 2;
swap_ptr(&a, &b);
// now a=2, b=1
\end{lstlisting}
\misc{
	\ctext{\&a} uses the \textbf{reference} operator to get the address of \ctext{a}.
	
	\ctext{*x} uses the \textbf{dereference} operator to get / set the value at the address given by \ctext{x}.
}
\end{frame}
{'fraction_non_alphanumeric': 0.3467987804878049, 'fraction_numerical': 0.009146341463414634, 'mean_word_length': 4.706521739130435, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3601912', 'n_tokens_mistral': 959, 'n_tokens_neox': 873, 'n_words': 260}