from long to string

In c++ how would I go about type casting a long to a string? I've done the following and had it not work:
str=string(_long);

What is the correct way to do this?

Comments

  • [b][red]This message was edited by stober at 2003-2-16 18:24:11[/red][/b][hr]
    : In c++ how would I go about type casting a long to a string? I've done the following and had it not work:
    : str=string(_long);
    :
    : What is the correct way to do this?
    :

    [blue]you have to convert it to a string -- type casting will not work.
    [code]
    #include

    int main()
    {
    char buffer[16];
    int number = 12345;
    sprintf(buffer,"%d", number);
    printf("s
    ",buffer);
    return 0;
    }
    [/code]


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion