• C Notes 1 (Pages: 102)

      Brief history of C, Tokenizing the C source, sizeof for various data types, printf, data types, conversion, specifiers/characters, signed and unsigned, 2's complement representation, overflow, truncation, Creating 'preprocessed only' output in gcc, limits.h, constants, %e, %f, %g, %LE, %LF, %LG, double constants, multi-character character constants, '\0', The ubiquitous mistake: (i=3) and (i==3), The sizeof operator (and keyword), enumeration using enum, Floating Point number representation: The IEEE-754, UL suffix, % operator, division by zero, floating point exception, Conversion rules in C, Assignment rules in C: i+++j, i++++j, i+++++++j, static, const, auto, &, &&, |, ||, !, ~, ^; Why C doesn't have a logical XOR operator? Suffices l, L, ll, LL, lL, Ll; long long data type; hex representation, negative 0, negative octa number, char constants, floating point constants, string constants; Predicting the outputs with : && and || (order of evaluation is specified); +=, -+, *=, /=, shift operators (< and="">>); Comma operator (the lowest precedence operator), What is meant by 'size effect' in C?, The only operators where the order of evaluation is specified: &&, ||, , and ?:, Conditional expression --> ?:, The 'lvalue' and 'rvalue'; integer promotion; scanf, fscanf, conversion specification with scanf function; Floating point numbers and scanf; Pointer value and scanf; [...], [^...] in scanf; switch statement; while, for, continue, reak; getchar and putchar (macros), errno values, Error indications in C: , clearerr(), feof(), ferror(), perror(), strerr(),strerr_r(), fgetc(), fputc(), getw(), putw(), fputs(), puts(), fgets(), gets(), Palindrome, array subscripts should be integer types, integer promotion rules, Familiarising the headers: , Control character, NULL character, poison null, EOT, Bell, Echo, Line Feed, Carriage return etc. LCM algorithm, Program to print 'Hello World' without using the ';' character. Proof: 'A Composite number can be expressed as a product of primes in a unique way'. Proof: 'Every factors of a positive integer n should be less than or equal to (n/2)'.

  • C Notes 2 (Pages: 94)

      exit(), _exit(), Function prototypes, Why return type of getchar() is int, Function arguments, parameters, return expression, External variables and scope in functions, extern keyword, Multi-file compilation of a C program, -combine, -save-temps, -S, -c, Function prototypes inside functions, function prototype rules, static variables and function, automatic variables, Declaration rules, Initialization of array elements, Recursion, Factorial, Fibonacci, Macros in C, multiline macros, -E option in gcc, macros in ctype.h, quoted strings in macros, macros with arugments, # (stringizing operator), ## (token-pasting operator), Storage class specifiers: auto, extern, register, static, typedef, Rules to remember when defining macros, External declarations, definitions, scope, linkage, Array initializations, array and pointers, multi-dimensional arrays, pointer to pointers, array of pointers, pointer to arrays (30 pages), Command line arguments, Pointers to functions, fflush(), man --> section 1, 2, 3, curses library for graphics in C (20 pages), Structures in C, declaration, dot operator, unnamed structures & unions, nesting of structures, array of structures, valid operations on structure variables, passing/returning of structures to/from functions, pointers to structures, arrow operator, Ctrl + D, Enter, holes in structures (implementation dependent rules), alignment and size of structures, Byte alignment restrictions, byte padding rules, byte ordering, big and little endianness, data structure alignment, CISC & RISC processors, self-referential structures, incomplete types in structures, mutually recursive structures, bit-fields, -fpack-struct switch in gcc, data alignment of structures in gcc, bit-fields, 'almost everything about bit-fields is implementation dependent', Sample codes involving structures and bit-fields, short-circuit evaluation with && and ||, why expressoins inside brackets are not evaluated first, Some miscellaneous code snippets, main is not a keyword, string literal/constant, type qualifier, type specifier, FILE * pointer, struct _IO_FILE{ ... }

  • C Notes 3 (Pages: 97)

      File handling in C, modes of opening file: r, w, a, r+, w+, a+, binary files, fread, fwrite, dynamic memory allocation, calloc, malloc, free, realloc, The Russian peasant algorithm for number multiplication (using only multiplication and division by 2 and addition), function pointers declaration - different ways, typedef struct _IO_FILE FILE, struct _IO_FILE, fopen modes, file positioning functions, fseek, ftell, rewind, fgetpos, fsetpos, explicit type conversion, file program: using fopen, ftell, feof, getc; function pointer program, case keyword sample pgm, printf("10", 10), switch and label - sample pgm, undefined behavior, implementation, argument, parameter, value, program structure, program startup, sequence points, side effects, set of sequnce points available, free-standing and hosted execution environments, i++ passed to function, pointer with ++, * and -- operators: sample code, arrow operator code, dot operator, pointer to integer array of size 2; i = 2, 3 --> syntax error; i = (2, 3) --> valid stmt, structure sample code, array of function pointers, complicated declarations I, complicated declarations II, multidimensional arrays in C - array of arrays - how to predict the output; passing functions to other functions. extern & static pgm, ldd - print shared library dependencies; hexdump command, od command, readelf command, echo command, Where the same file can be opened simultaneously is implementation defined; deleting a file using remove(), rename() function, tmpfile() function, qsort() function, bsearch() function, Program library - shared, static and dynamically loaded (DL) libraries; ar command (gnu development tools) to create archive, Example for creating static library, calling an external program in C (linux), system() function, fork() command, segments in elf: .text, .bss, .data, .symtab, .interp; exec() system call, copy-on-write (cow), vfork(), _exit() and exit(), fork() sample code, wait(), waitpid(), waitid(), sample code, Predicting output for x[3][2][5]; Processes and signals, process structure, ps command, init process, /proc directory, Process table, ps command, init - the mother of them all; getty, runlevel, changing runlevels, skipping init, getty (get teletype) in unix, process scheduling, ps command, nice value, nice command (niceness should not be confused with scheduling priority), examples, Starting a new process with system(), sh command, replacing a process image, exec family of function calls, execl, execlp, execle, execv, execvp, sample code using exec functions, environment variables, getenv(), clearenv(), setenv(), unsetenv(), duplicating a process image, pstree command, "Does forking creates duplicate copies of the code (.text) segment for the child and the parent?", fork-exec technique, overlaying, SIGCHLD, filters in unix, chain loading, pseudo terminal, tty command, grantpt(), unlockpt(), copy-on-write (cow) technique, orphan process, SIGHUP, adopted by init, daemon process, Maxwell's daemon (the though experiment), Method for a process to become a daemon, list of service daemons for UNIX like systems, windows equivalent, TSR (Terminate and Stay Resident) programs, Services in Windows, daemon etymology, File attributes in linux, ls command, struct stat, #include, stat, fstat, lstat; mode_t, st_mode, struct stat, sample code using struct stat, file owner in linux, chown() function call - change owner; fchown() call, mode-bits for permission, sample code to print the file details, sticky bits

  • C Notes 4 (Pages: 98)

      Assigning file permissions, umask command, read_umask(), get_umask(), chmod(), fchmod(), creat(), write(), 'time' command in linux; real, user and system time; CamelCase; snake case; lazy program theory; alto keyboard theory, hungarian notation; unspecified and undefined behaviour; digress: Visicalc; @ symbol; Raymond Tomilson; perfect number; digress: proof for '2^(p-1) * (2^p - 1)' is an even perfect number whenever 2^(p-1) is prime. (2^p - 1) is prime only when p is prime; mersenne primes; strong law of small numbers, Every even perfect number of the form '2^(p-1) * (2^p - 1)' is represented in binary as P ones followed by (p-1) zeroes. Mersenne number; 2^p - 1, GIMS (Great Internet Mersenne Prime Search), George Woltman, Prime95, MPrime; Interrupts & Signals, raise(), kill(), signal.h, signal(), pthread_kill, digress: EFF(Electronic Frontier Foundation), Larry Wall, Perl, 'Benevolent Dictator for Life'; Mark Shuttelworth; Signal handling, abort(), alarm(), segmenation fault: bus error, non_existent address, unaligned access, segmentation/page fault, __asm__, bus error example code, pipeline (in Linux/UNIX), '|', background tasks using '&', pipe(), write(), read(), The C standard library, 24 header files, assert.h, complex.h, ctype.h, errno.h, fenv.h (floating-point environment), float.h, inttypes.h, iso646.h (iso646 variant character sets), limits.h, locale.h, math.h, setjmp.h (non-local exits), stdarg.h, stdbool.h, stdint.h, stddef.h, stdio.h, stdlib.h, string.h, tgmath.h, time.h, wchar.h, wctype.h, glibc, libc.so, __STDC_HOSTED__, hosted and free-standing libraries, buffer-overflow vulnerabilities in C library, stdbool.h, digress: ad infinitum; stdint.h, int8_t, int16_t, int32_t, uint8_t, uint16_t, uint32_t, minimum width integer types, fastest integer types with minimum widths specified, integer types capable of holding object pointers, greatest width integer types, memory segmentation, digress: Trusted Platform Module, Crypto-processor, scare quotes around 'trusted computing', SSDs & HDDs comparison, single level cell (SLC) and multi-level cell (MLC) - comparison, read \amp write cycles, 4KB pages, TRIM command, gets slower the more you fill it up, 'block' - the smallest structure you can erase in a NAND flash device, logical block addressing, overwriting files - in HDDs and SSDs, SSD controller, Why SSDs gets slower the more you use them? TRIM command, awk tutorial - language for processing files of text, POSIX awk, GNU Awk, sed, awk is turing complete, 'a line is scanned for each pattern in the program and for each pattern that matches, the associated action is taken', awk { }, BEGIN and END clause, NR - number of records, -F option, initializing awk variables on the command line, special characters, digress: chiclet keyboard, awk - continued, variables with specific functions - ARGC, FILENAME, NF, NR, FS, OFMT, OFS, ORS, RS; 'in' operator, SUBSEP variable, delete statement, relational expression in awk do not return a value, examples, built-in functions for Gawk, examples.

C Notes