changing datatypes

Discussion in 'C++' started by sudip chatterjee, Jul 23, 2003.

  1. can a signed 'int', 'long' or 'double' datatype be changed int 'char'
    without using any standard library functions...

    sudip
     
    sudip chatterjee, Jul 23, 2003
    #1
    1. Advertisements

  2. Sure

    int i = 1;
    int l = 2;
    double d = 3;
    char c1 = i;
    char c2 = l;
    char c3 = d;

    is that what you meant?

    john
     
    John Harrison, Jul 23, 2003
    #2
    1. Advertisements

  3. sudip chatterjee

    John Dibling Guest

    Sure, but you will have to use some function to do basically what
    itoa() and sprintf() do. You might even have write that function
    yourself. There is nothing magic in any of the standard library
    functions, just code.

    BTW - I am assuming you are trying to get a number formatted as a
    string, as accomplished like this: sprintf( psz, "%i",
    nNumberToFormat);

    </dib>

    John Dibling
    email: dib@substitute_my_full_last_name_here.com
    Witty banter omitted for your protection
     
    John Dibling, Jul 23, 2003
    #3
  4. I meant to type

    long l = 2;

    john
     
    John Harrison, Jul 23, 2003
    #4
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.