Last change
on this file since 5c13d64 was 5c13d64, checked in by Thomas Lopatic <thomas@…>, 7 years ago |
Use void pointers for mem*() functions.
|
-
Property mode
set to
100644
|
File size:
478 bytes
|
Rev | Line | |
---|
[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | memchr.c -- search a string for a character
|
---|
| 4 | Version 1 -- 1987-06-12
|
---|
| 5 |
|
---|
[5c13d64] | 6 | Return the ptr in vp at which the character c appears;
|
---|
[f40a309] | 7 | NULL if not found in n chars; don't stop at \0.
|
---|
| 8 | =============================================================================
|
---|
| 9 | */
|
---|
| 10 |
|
---|
[5c13d64] | 11 | void *memchr(void *vp, char c, int n)
|
---|
[f40a309] | 12 | {
|
---|
[5c13d64] | 13 | char *cp = vp;
|
---|
| 14 |
|
---|
| 15 | while (--n >= 0)
|
---|
| 16 | if (*cp++ == c)
|
---|
| 17 | return(--cp);
|
---|
| 18 |
|
---|
| 19 | return((void *)0);
|
---|
[f40a309] | 20 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.