当前位置: 首页 > 工具软件 > X-Mem > 使用案例 >

Mem.h 常用函数

程祺
2023-12-01
  1. asdf asdfasdfasdf fasdfasd
    dfasdf adf assdf asdf sad dfasdf adf assdf asdf sad dfasdf adf assdf asdf sad dfasdf adf assdf asdf sad dfasdf adf assdf asdf sad dfasdf adf assdf asdf sad dfasdf adf assdf asdf sad \

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstring>

int main(int argc, char* argv[])
{
    char arr[100];
    char* temp = "Landon.Yu";
    char* mode = "/home/linux/Destop/";

    int ret = 0;
    int arrLen = sizeof(arr);
    int modeLen = strlen(mode);
    int tempLen = strlen(temp);



    memset(arr, '\0', arrLen);
    printf("******************************************************************\n");
    printf("输出在下方:↓   \n");
    for(int i = 0; i < arrLen; ++i){
        printf("%c ", arr[i]);
        if(0 == ((i + 1) % 10)){
            printf("\n");
        }
    }
    printf("******************************************************************\n\n");

    memset(arr, '1', arrLen);
    printf("******************************************************************\n");
    printf("输出在下方:↓   \n");
    for(int i = 0; i < arrLen; ++i){
        printf("%c ", arr[i]);
        if(0 == ((i + 1) % 10)){
            printf("\n");
        }
    }
    printf("******************************************************************\n\n");

    //memset(arr, '1', N - 1);
    printf("******************************************************************\n");
    printf("输出在下方:↓   \n");
    printf("arrLen= %d\nmodeLen= %d\ntmepLen= %d\n", arrLen, modeLen, tempLen);
    printf("******************************************************************\n\n");

    ret = snprintf(arr, (modeLen + tempLen), "%s%s", mode, temp);
    printf("******************************************************************\n");
    printf("输出在下方:↓   \n");
    printf("arr: %s\nmode: %s\ntemp: %s\nret = modeLen + tempLen = %d + %d = %d\nret = %d\n",
            arr, mode, temp, modeLen, tempLen, (modeLen + tempLen), ret);
    printf("******************************************************************\n\n");

    return 0;
}


 类似资料: