• 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  编译运行:

  • 相关阅读:
    sql server 的变量
    psycopg2 (python与postgresql)
    sublime text3 设置快速生成代码
    关于 Form 表单的 enctype 属性
    根据二进制流判断文件类型
    URL编码和Base64编码 (转)
    GZip 压缩及解压缩
    HttpWebRequest 请求 Api 及 异常处理
    c# BinaryWriter 和 BinaryReader
    JQ 上传文件(单个,多个,分片)
  • 原文地址:https://www.cnblogs.com/lgh1992314/p/5835360.html
Copyright © 2020-2023  润新知