c convert char pointer and char array interactively via strcpy

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <uuid/uuid.h>

void chArrayToCharP6()
{
    char chArr[110]="4dec892c-c083-4515-9966-9e0303be4239,4dec892c-c083-4515-9966-9e0303be4239,4dec892c-c083-4515-9966-9e0303be4239";
    char *msg=(char*)malloc(strlen(chArr));
    strcpy(msg,chArr);
    printf("Msg=%s,length=%ld\n",msg,strlen(msg));
}

void covertCharPToArray5()
{
    char *msg=(char*)malloc(40);
    retrieveUuid4(msg);
    printf("Msg=%s,length=%ld,size=%ld\n",msg,strlen(msg),sizeof(msg));
    char chArr[strlen(msg)];
    strcpy(chArr,msg);
    printf("Charr=%s,lenghth=%ld,size=%ld\n",chArr,strlen(chArr),sizeof(chArr));
    free(msg);
}

 

posted @ 2021-11-28 17:44  FredGrit  阅读(21)  评论(0编辑  收藏  举报