#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main() {
printf("1. Writing a space character\n");
write(1, " ", 1);
printf("2. Writing an integer\n");
int i = 20;
write(1, &i, sizeof(i));
printf("3. Writing a character\n");
char c = 'a';
write(1, &c, 1);
printf("4. Writing a short\n");
short s = 99;
write(1, &s, sizeof(s));
printf("5. Writing a string\n");
char *str = "Hello, world!";
write(1, str, strlen(str));
printf("6. Writing an array of integers\n");
int arr[] = {1, 2, 3, 4, 5};
write(1, arr, sizeof(arr));
printf("7. Writing a formatted string\n");
int num = 123;
char buffer[20];
sprintf(buffer, "The number is %d", num);
write(1, buffer, strlen(buffer));
printf("8. Writing binary data\n");
float f = 3.14;
write(1, &f, sizeof(f));
printf("9. Writing data from a buffer\n");
char buffer2[1024];
// Fill buffer2 with data...
write(1, buffer2, sizeof(buffer2));
printf("10. Writing data from a struct\n");
struct {
int id;
char name[20];
} person;
printf(": Populate person...\n");
write(1, &person, sizeof(person));
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: