22 Jan 2004 lukeg   » (Master)

Example 8
---------
 
"C" provides a conditional expression.
Thus if "a" and "b" are integer vari-
ables,
 
        (a > b ? a : b)
 
is an expression whose value is that of
the larger of "a" and "b".
 
 
However this does not work if "a" and
"b" are to be regarded as unsigned 
integers. Hence there is a use for the
procedure
 
6326 max (a, b)
     char *a, *b;
     {
       if (a > b)
         return(a);
       return(b);
     }
 
The trick here is that "a" and "b",
having been declared as pointers to
characters are treated for comparison
purposes as unsigned integers.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!