Skip to content

Commit

Permalink
Resolves #46
Browse files Browse the repository at this point in the history
  • Loading branch information
bhuvy2 committed Feb 1, 2019
1 parent 0eb751e commit f241eef
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions introc/introc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1502,5 +1502,41 @@ \section{Questions/Exercises}
What are some differences between the POSIX filedescriptor model and C's \keyword{FILE*} (ie what function calls are used and which is buffered)? Does POSIX use C's \keyword{FILE*} internally or vice versa?
\end{itemize}

\section{Rapid Fire: Pointer Arithmetic}

Pointer arithmetic is really important! You need to know how many bytes each pointer is moved by with each addition. The following is a rapid fire section. We'll use the following definitions

\begin{lstlisting}[language=C]
int *int_; // sizeof(int) == 4;
long *long_; // sizeof(long) == 8;
char *char_;
int *short_; //sizeof(short) == 2;
int **int_ptr; // sizeof(int*) == 8;
\end{lstlisting}

How many bytes are moved over from the following additions?

\begin{enumerate}
\item \keyword{int_ + 1}
\item \keyword{long_ + 7}
\item \keyword{short_ - 6}
\item \keyword{short_ - sizeof(long)}
\item \keyword{long_ - sizeof(long) + sizeof(int_)}
\item \keyword{long_ - sizeof(long) / sizeof(int)}
\item \keyword{(char*)(int_ptr + sizeof(long)) + sizeof(int_)}
\end{enumerate}

\subsection{Rapid Fire Solutions}

\begin{enumerate}
\item 4
\item 56
\item -12
\item -16
\item 0
\item -16
\item 72
\end{enumerate}

\bibliographystyle{plainnat}
\bibliography{introc/introc}

0 comments on commit f241eef

Please sign in to comment.