I want to store a string to a char array inside a structure and when I access the char array I want the result to be displayed along with the value from the global variable errCode. When I access the errDesc member of the structure then I want the result to be "Error detected with error code 0xA0B0C0D0", but since using strcpy copies the string as it is I am getting a result "Error detected with error code %08lx" . Here is a sample code which replicates my issue:
int errCode = 0xA0B0C0D0;
void function(errpacket* ptr, int a, char* errString, ...);
typedef struct{
    int err;
    char errDesc;
}errpacket;
int main(){
    errpacket* a;
    void function(a, 10, "Error detected with error code %08lx", errCode);
    return 0;
}
void function(errpacket* ptr, int a, char* errString, ...){
    ptr->err = a;
    strcpy(&ptr->errDesc, errString);
}
If my implementation is incorrect, please suggest me a way to do what I intend to. Also please point out the mistakes in the above code.
 
     
     
     
     
    