Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,970 questions

51,912 answers

573 users

How to use itoa with scanf() in C

1 Answer

0 votes
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char buffer[32];
    int i;

    printf("Enter a number: ");
    if (scanf("%d", &i) == 1) {
        _itoa(i, buffer, 10);
        printf("decimal: %s\n", buffer);
        _itoa(i, buffer, 16);
        printf("hexadecimal: %s\n", buffer);
        _itoa(i, buffer, 2);
        printf("binary: %s\n", buffer);
    }

    return 0;
}




/*
run:
 
Enter a number: 255
decimal: 255
hexadecimal: ff
binary: 11111111
 
*/

 



answered Dec 7, 2022 by avibootz

Related questions

1 answer 76 views
76 views asked Dec 7, 2022 by avibootz
2 answers 267 views
1 answer 94 views
1 answer 77 views
2 answers 112 views
1 answer 193 views
...