There is yet another way to print useful code to the terminal in C.
This program below shows a very simple way to print text to the terminal and this is not using printf().
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include <sys/uio.h> int main(void) { struct iovec buffers[4]; buffers[0].iov_base = "party"; buffers[0].iov_len = 5; buffers[1].iov_base = " "; buffers[1].iov_len = 1; buffers[2].iov_base = "on"; buffers[2].iov_len = 2; buffers[3].iov_base = " dude.\n"; buffers[3].iov_len = 5; writev(1, buffers, 4); return 0; } |
I found this code here: https://flylib.com/books/en/1.381.1.84/1/.
But this is a very useful way to make a super simple Hello World program.
1 2 3 4 5 6 7 8 9 10 11 | #include <sys/uio.h> int main(void) { struct iovec buffers[1]; buffers[0].iov_base = "Hello World."; buffers[0].iov_len = 12; writev(1, buffers, 1); return 0; } |
The above is another very simple C program. This prints Hello World and is as simple as it can get.