现在的位置: 首页 > 综合 > 正文

strnset ( )【C语言库函数源代码】

2013年08月13日 ⁄ 综合 ⁄ 共 409字 ⁄ 字号 评论关闭

C语言库函数源代码】

【本程序在Dev C++ 4.9.9.2 下编译通过】

/*

   Sets the first count characters of string the character value.

If the length of string is less than count, the length of string is used in place of n.

   把字符串的前count个字符设置为字符val。

*/

char * my_strnset(char * str,int val,int count)

{

   char *p = str;

   while (count-- && *p)

      *p++ = (char)val;

   return(p);

}

int main()

{

   char str[] ="ammana_babi";

   my_strnset(str,'*',strlen(str)-4);

   puts(str);

   system("pause");

   return 0;

}

抱歉!评论已关闭.