#include <unistd.h>
#include <stdio.h>


int main() {
    //using printf

    char cbb = 'b'; 
    printf("%c %d ", cbb, cbb);
    printf("\n");


    //using write
    char cb = 'b';
    write(1, &cb, 1); //'b'
    
    //convert char to ASCII value
    int ascii_value = (int)cb;
    char ascii_value_str[4]; // Assuming ASCII value won't exceed 3 digits
    int len = sprintf(ascii_value_str, " %d", ascii_value);
    
    write(1, ascii_value_str, len); // Writing the ASCII value as a string


    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: