xref: /csrg-svn/lib/libc/string/memchr.c (revision 34479)
124195Skre /*
224195Skre  * Copyright (c) 1985 Regents of the University of California.
3*34479Sbostic  * All rights reserved.
4*34479Sbostic  *
5*34479Sbostic  * Redistribution and use in source and binary forms are permitted
6*34479Sbostic  * provided that this notice is preserved and that due credit is given
7*34479Sbostic  * to the University of California at Berkeley. The name of the University
8*34479Sbostic  * may not be used to endorse or promote products derived from this
9*34479Sbostic  * software without specific written prior permission. This software
10*34479Sbostic  * is provided ``as is'' without express or implied warranty.
1124195Skre  */
1224195Skre 
1326526Sdonn #if defined(LIBC_SCCS) && !defined(lint)
14*34479Sbostic static char sccsid[] = "@(#)memchr.c	5.3 (Berkeley) 05/25/88";
15*34479Sbostic #endif /* LIBC_SCCS and not lint */
1624195Skre 
1724195Skre char *
1824195Skre memchr(s, c, n)
1924195Skre 	register char *s;
2024195Skre 	register c, n;
2124195Skre {
2224195Skre 	while (--n >= 0)
2324195Skre 		if (*s++ == c)
2424195Skre 			return (--s);
2524195Skre 	return (0);
2624195Skre }
27