~~~~~~~Forum Diskusi Software dan Internet untuk Kristen-Katolik~~~~~~~


> From: Daniel Suryadarma
> 
> Saya mau nanya, prosedur mengubah int ke string di MSVC++ apa ya?
> Kalau di Java kan tinggal ""+int-nya, tapi di c++ ndak jalan.

gimana kalo pake itoa()?

        #include <stdlib.h> 
        char *itoa(int value, char *string, int radix); 

value = nilai integer yang mau diubah ke string
string = jumlah buffer yang menampung string
radix = base-nya, antara 2-36, kalo normal pake desimal atau 10

contoh:
        #include <stdio.h>
        #include <stdlib.h>

        int main( void )
        {
            char buffer[20];
            int base;

            for( base = 2; base <= 16; base += 2 ) {
                printf( "%2d %s\n", base,
             itoa( 12765, buffer, base ) );
                }
        return;
        }

hasilnya kurang lebih bakal jadi:
         2 11000111011101
         4 3013131
         6 135033
         8 30735
        10 12765
        12 7479
        14 491b
        16 31dd




------ Hemat Bandwith : Hapus pesan yang tidak perlu sebelum reply ------
SUBSCRIBE---> To:   [EMAIL PROTECTED], Isi/Body: kosong
UNSUBSCRIBE---> To: [EMAIL PROTECTED], Isi/Body: kosong
Moderator: Ronny <[EMAIL PROTECTED]>, Alex <[EMAIL PROTECTED]>
Web : http://hub.xc.org/cgi-bin/lyris.pl?enter=i-kan-software

Kirim email ke