[SPCA] Restructre, some notes

This commit is contained in:
2026-01-04 13:59:33 +01:00
parent c7618f38a4
commit 4550168877
9 changed files with 22 additions and 10 deletions

View File

@@ -12,5 +12,5 @@ int main( int argc, char *argv[] ) {
for ( int i = 0; i < argc; i++ ) // For loop just like any other sane programming language for ( int i = 0; i < argc; i++ ) // For loop just like any other sane programming language
printf( "Arg %d: %s\n", i, argv[ i ] ); // Outputs the i-th argument from CLI printf( "Arg %d: %s\n", i, argv[ i ] ); // Outputs the i-th argument from CLI
get_user_input_int( "Select a number" ); get_user_input_int( "Select a number" ); // Function calls as in any other language
} }

View File

@@ -25,12 +25,12 @@ int get_user_input_int( char prompt[] ) {
while ( input_data > 1 ) { while ( input_data > 1 ) {
input_data -= 1; input_data -= 1;
printf( "Hello World" ); printf( "Hello World\n" );
} }
do { do {
input_data -= 1; input_data -= 1;
printf( "Bye World" ); printf( "Bye World\n" );
} while ( input_data_copy > 1 ); } while ( input_data_copy > 1 );
return 0; return 0;

View File

@@ -1,13 +1,15 @@
I can clearly C why you'd want to use C. Already sorry in advance for all the bad C jokes that are going to be part of this section \begin{scriptsize}
\textit{I can clearly C why you'd want to use C. Already sorry in advance for all the bad C jokes that are going to be part of this section}
\end{scriptsize}
\texttt{C} is a compiled, low-level programming language, lacking many features modern high-level programming languages offer, like Object Oriented programming, \texttt{C} is a compiled, low-level programming language, lacking many features modern high-level programming languages offer, like Object Oriented programming,
true Functional Programming (like Haskell implements), Garbage Collection, complex abstract datatypes and vectors, just to name a few. true Functional Programming (like Haskell implements), Garbage Collection, complex abstract datatypes and vectors, just to name a few.
(It is possible to replicate these using Preprocessor macros, more on this later). (It is possible to replicate these using Preprocessor macros, more on this later).
On the other hand, it offers the ability to directly integrate assembly code into the \texttt{.c} files, On the other hand, it offers low-level hardware access, the ability to directly integrate assembly code into the \texttt{.c} files,
as well as bit level data manipulation and extensive memory management options, again just to name a few. as well as bit level data manipulation and extensive memory management options, again just to name a few.
This of course leads to \texttt{C} performing excellently and there are many programming languages who's compiler doesn't directly produce machine code or assembly, This of course leads to \texttt{C} performing excellently and there are many programming languages whose compiler doesn't directly produce machine code or assembly,
but instead optimized \texttt{C} code that is then compiled into machine code using a \texttt{C} compiler. but instead optimized \texttt{C} code that is then compiled into machine code using a \texttt{C} compiler.
This has a number of benefits, most notably that \texttt{C} compilers can produce very efficient assembly, This has a number of benefits, most notably that \texttt{C} compilers can produce very efficient assembly,
as lots of effort is put into the \texttt{C} compilers by the hardware manufacturers. as lots of effort is put into the \texttt{C} compilers by the hardware manufacturers.

View File

@@ -1,6 +1,13 @@
\subsection{The Syntax} \subsection{The Syntax}
\texttt{C} uses a very similar syntax as many other programming languages, like \texttt{Java}, \texttt{JavaScript} and many more\dots \texttt{C} uses a very similar syntax as many other programming languages, like \texttt{Java}, \texttt{JavaScript} and many more\dots
to be precise, it is \textit{them} that use the \texttt{C} syntax, not the other way around. So: to be precise, it is \textit{them} that use the \texttt{C} syntax, not the other way around. So:
\inputcodewithfilename{c}{code-examples/00_c/01_syntax/}{00_intro.c} \inputcodewithfilename{c}{code-examples/00_c/}{00_intro.c}
\inputcodewithfilename{c}{code-examples/00_c/01_syntax/}{01_func.h}
\inputcodewithfilename{c}{code-examples/00_c/01_syntax/}{01_func.c} In \texttt{C} we are referring to the implementation of a function as a \bi{(function) definition} (correspondingly, \textit{variable definition}, if the variable is initialized)
and to the definition of the function signature (or variables, without initializing them) as the \bi{(function) declaration} (or, correspondingly, \textit{variable declaration}).
\texttt{C} code is usuallt split into the source files, ending in \texttt{.c} (where the local functions and variables are declared, as well as all function definitions)
and the header files, ending in \texttt{.h}, where the external declarations are defined. Usually, no definition of functions are in the \texttt{.h} files
\inputcodewithfilename{c}{code-examples/00_c/}{01_func.h}
\inputcodewithfilename{c}{code-examples/00_c/}{01_func.c}

Binary file not shown.

View File

@@ -4,6 +4,9 @@
\setup{Systems Programming and Computer Architecture} \setup{Systems Programming and Computer Architecture}
\usepackage{lmodern}
\setFontType{sans}
\begin{document} \begin{document}
\startDocument \startDocument
\usetcolorboxes \usetcolorboxes