zoukankan      html  css  js  c++  java
  • memset函数

    函数原型:extern void *memset(void *buffer, int c, int count)

    参数说明:buffer为源字符串,c为要初始化的字符的值,count为初始化buffer中字符的个数。
            
    所在库名:#include <string.h>
      
    函数功能:把buffer所指内存区域的前count个字节设置成字符c。
      
    返回说明:返回void*类型指针。

    其它说明:通常可以用它来初始化数组的信息,这样使用很方便。

    实例:

        #include<string.h>
        #include
    <stdio.h>
        
    int main()
        
    {
            
    char str[100]="Hello,I am sky2098,I liking programing!";
            
    char character='H' ;  //指定一个字符
            void *voidtemp;
            printf(
    "Before Setting the str is:   %s ! ",str);
            voidtemp
    =memset(str,character,strlen("Hello,I am sky2098"));
            
    if(voidtemp!=NULL)
            
    {
                printf(
    "Set Success! ");
                printf(
    "After Setting the str is:   %s ! ",str);
            }

            
    else
            
    {
                printf(
    "Set Failure! ");
                printf(
    "After Setting the str is:   %s ! ",str);

            }

            
    return 0;
        }

    在VC++ 6.0  编译运行:

  • 相关阅读:
    收藏的日历js算法 很实用
    autofac system.core 的版本问题
    and 组件ui等
    vc相关
    live传264流
    录转rtsphan
    ndk errno
    cpp all记录
    and 录音等+live等
    cmake
  • 原文地址:https://www.cnblogs.com/lgh1992314/p/5835360.html
Copyright © 2011-2022 走看看