Thinking in C and *nix (CSC 295/282 2014S) : Outlines
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [Teaching & Learning] - [Calendar]
Current: [Outline] [EBoard] [Lab] [Assignment]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines]
Reference: [EBook] - [ISO] [GNU Coding Standards] [GCC Documentation] - [TAoUP] [Make3]
Related Courses: [CSC 295 2013S]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker]
Held: Thursday, 24 April 2014
Back to Outline 11 - Debugging with GDB. On to Outline 13 - Variadic Functions.
Summary
We consider a variety of smaller issues that might make you a better C programmer.
Related Pages
Overview
assert. (Already covered this year.)Administrivia
i = 5; // I assume i is 5 foo (i); // I assume i is still 5, since C is a pass-by-value language
assert macro takes as parameter a Boolean expression,
executes the expression, and, if it fails, terminates the program and
reports the line at which it terminated./** * Sort an array of strings alphabetically. */ int strings_sort (int n, char *strings[])
/** * Sort an array of strings using comparator. */ int strings_sort (int n, char *strings[], "*something-that-compares-strings*" compare)
function pointer
int strings_sort (int n, char *strings[],
int (*compare)(char *str1, char *str2));
int (*binary_integer_function)(int x1, int x2);
StringComparator)typedef before the
declaration. (Yeah, that's how typedef always seems to work.)typedef int (*StringComparator)(char *str1, char *str2);
int strings_sort (int n, char *strings[], StringComparator compare);
(*compare)(str1, str2)
compare (str1, str2);
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [Teaching & Learning] - [Calendar]
Current: [Outline] [EBoard] [Lab] [Assignment]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines]
Reference: [EBook] - [ISO] [GNU Coding Standards] [GCC Documentation] - [TAoUP] [Make3]
Related Courses: [CSC 295 2013S]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker]
Copyright (c) 2013-14 Samuel A. Rebelsky.

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this
license, visit http://creativecommons.org/licenses/by/3.0/
or send a letter to Creative Commons, 543 Howard Street, 5th Floor,
San Francisco, California, 94105, USA.