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

int main() {
    printf("1. Writing a space character\n");
    write(1, " . ", 3);
    write(1, "\n", 1);

    printf("2-1. Writing an integer\n"); //output:blank
    int i = 20;
    write(1, &i, sizeof(int));
    write(1, "\n", 1);

    printf("2-2. Writing an integer\n"); //output:20
    int in = 20;
    char int_str[20]; // Buffer to hold the string representation of the integer
    sprintf(int_str, "%d", in); // Convert integer to string
    write(1, int_str, strlen(int_str)); // Write the string
    write(1, "\n", 1);

    printf("3. Writing a character\n");
    char c = 'a';
    write(1, &c, 1);
    write(1, "\n", 1);


    return 0;
}

Embed on website

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