#include <fcntl.h> // For open()
#include <unistd.h> // For read() and close()
#include <stdio.h> // For printf()
int main() {
int a = open("test.txt", O_RDONLY); // Open "test.txt" in read-only mode
char b[11]; // Declare a character array of size 11
read(a, b, 10); // Read up to 10 characters from the file into b
b[10] = '\0'; // Add null terminator at the end of the string
printf("%s", b
); // Print the contents of b close(a); // Close the file
return 0;
}
I2luY2x1ZGUgPGZjbnRsLmg+ICAgLy8gRm9yIG9wZW4oKQojaW5jbHVkZSA8dW5pc3RkLmg+ICAvLyBGb3IgcmVhZCgpIGFuZCBjbG9zZSgpCiNpbmNsdWRlIDxzdGRpby5oPiAgIC8vIEZvciBwcmludGYoKQoKaW50IG1haW4oKSB7CiAgICBpbnQgYSA9IG9wZW4oInRlc3QudHh0IiwgT19SRE9OTFkpOyAvLyBPcGVuICJ0ZXN0LnR4dCIgaW4gcmVhZC1vbmx5IG1vZGUKICAgIGNoYXIgYlsxMV07IC8vIERlY2xhcmUgYSBjaGFyYWN0ZXIgYXJyYXkgb2Ygc2l6ZSAxMQogICAgcmVhZChhLCBiLCAxMCk7IC8vIFJlYWQgdXAgdG8gMTAgY2hhcmFjdGVycyBmcm9tIHRoZSBmaWxlIGludG8gYgogICAgYlsxMF0gPSAnXDAnOyAvLyBBZGQgbnVsbCB0ZXJtaW5hdG9yIGF0IHRoZSBlbmQgb2YgdGhlIHN0cmluZwogICAgcHJpbnRmKCIlcyIsIGIpOyAvLyBQcmludCB0aGUgY29udGVudHMgb2YgYgogICAgY2xvc2UoYSk7IC8vIENsb3NlIHRoZSBmaWxlCiAgICByZXR1cm4gMDsKfQo=