diff options
author | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2012-03-07 19:31:25 +0000 |
---|---|---|
committer | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2012-03-07 19:31:25 +0000 |
commit | 166cc47deaa1da2477806e3bb9a1c6bd0b94ff52 (patch) | |
tree | 12c479e061d53a1ec8c9bf0451e84ac191323792 /libc/manual/examples/search.c | |
parent | 68958b4bf50cfd014e72d20fbe187f4d1ddee22f (diff) |
Merge changes between r17384 and r17457 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@17458 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/manual/examples/search.c')
-rw-r--r-- | libc/manual/examples/search.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/libc/manual/examples/search.c b/libc/manual/examples/search.c index 182e6e4a3..e37656721 100644 --- a/libc/manual/examples/search.c +++ b/libc/manual/examples/search.c @@ -1,3 +1,20 @@ +/* Searching and Sorting Example + Copyright (C) 1991-2012 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, if not, see <http://www.gnu.org/licenses/>. +*/ + #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -35,7 +52,7 @@ int count = sizeof (muppets) / sizeof (struct critter); /* This is the comparison function used for sorting and searching. */ -int +int critter_cmp (const struct critter *c1, const struct critter *c2) { return strcmp (c1->name, c2->name); @@ -44,7 +61,7 @@ critter_cmp (const struct critter *c1, const struct critter *c2) /* Print information about a critter. */ -void +void print_critter (const struct critter *c) { printf ("%s, the %s\n", c->name, c->species); @@ -54,7 +71,7 @@ print_critter (const struct critter *c) /*@group*/ /* Do the lookup into the sorted array. */ -void +void find_critter (const char *name) { struct critter target, *result; |