function - How to output single character in C with write? -
could instruct me on how print single letter, example "b" in c while using write function (not printf).
i'm pretty sure uses
#include <unistd.h>
could tell me how write properties work? don't understand
int write( int handle, void *buffer, int nbyte );
could of guys toss in few c beginner tips well?
i using unix.
you have found function, need pass proper parameters:
int handle = open("myfile.bin", o_wronly); //... need check result here int count = write(handle, "b", 1); // pass single character if (count == 1) { printf("success!"); }
i did indeed want use stdout. how write version display whole alphabet?
you use pre-defined constant stdout. called stdout_fileno
.
if write out whole alphabet, this:
for (char c = 'a' ; c <= 'z' ; c++) { write(stdout_fileno, &c, 1); }
Comments
Post a Comment