Cast from int to char + char concatenation

Discussion in 'C++' started by Konx, Mar 11, 2010.

  1. Konx

    Konx Guest

    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.
    Konx, Mar 11, 2010
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. walala
    Replies:
    3
    Views:
    4,775
    walala
    Sep 18, 2003
  2. Schnoffos
    Replies:
    2
    Views:
    1,190
    Martien Verbruggen
    Jun 27, 2003
  3. trey

    newbie: char* int and char *int

    trey, Sep 10, 2003, in forum: C Programming
    Replies:
    7
    Views:
    389
    Irrwahn Grausewitz
    Sep 10, 2003
  4. Hal Styli
    Replies:
    14
    Views:
    1,605
    Old Wolf
    Jan 20, 2004
  5. Randall Parker
    Replies:
    4
    Views:
    468
    Jack Saalweachter
    May 19, 2006
Loading...

Share This Page