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 chatterjee, Jul 23, 2003
    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 Harrison, Jul 23, 2003
    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",


    John Dibling
    Witty banter omitted for your protection
    John Dibling, Jul 23, 2003
  4. I meant to type

    long l = 2;

    John Harrison, Jul 23, 2003
    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.