Cast from int to char + char concatenation

K

Konx

Hi everyone.

I've already searched something related on internet and I've tried
various solutions, but they don't work.

Problem: I have a int variable and 2 char variable, and I want to
merge them into a single char variable. What I'm doing now is this:

int a = 3;
char* b;
b = (char*) a;
errorLabel
char *comm= "PULS:TRAN1 ";
char *end= "NS\n";
char *command;

command = new char[strlen(comm)+strlen(b)+strlen(fine)+1];

strcpy(command,comm);
strcat(command,b);
strcat(command,fine);

This is coming from a solution I've found on the web. This code is
compiling but then, when I run the program, it crashes.

What could be the problem?

Thanks for any help,

Konx.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top