C语言函数—memcpy

函数名

memchr

功 能

在数组的前n个字节中搜索字符

用 法

void *memchr(void *s, char ch, unsigned n);

程序例

#include <string.h> 
#include <stdio.h> 

int main(void) 
{ 
   char str[17]; 
   char *ptr; 

   strcpy(str, "This is a string"); 
   ptr = memchr(str, 'r', strlen(str)); 
   if (ptr) 
      printf("The character 'r' is at position: %dn", ptr - str); 
   else 
      printf("The character was not foundn"); 
   return 0; 
} 
  

如果引用本站的原创文章,请注明原文链接:,本站保留追究责任的权利!