+ 2

How to use the write function

#include <stdio.h> #include <unistd.h> int main(void) { char name[] = "Cobby Sefah Solomon"; /* 0 = stdin, 1 = stdout, 2 = sterr */ /* name = to indicate the name var */ /* 11 = the number of characters we want to print */ write(1, name, 11); return 0; } See write man to read more.

22nd Jul 2023, 12:52 PM
Cobby Sefah Solomon
Cobby Sefah Solomon - avatar
6 Antworten
+ 5
Write In C takes three parameters. 1st - where to write to. STDIN/ STDOUT or even a file. 2nd - What to write. Might be stored in a variable or file. 3rd - Number of characters to write.
22nd Jul 2023, 1:37 PM
Leeroy Mokua
Leeroy Mokua - avatar
+ 4
Hunter X Cobby the Q&A forum is reserved for specific programming questions or questions about Sololearn. If you have a question about the write statement, please state it clearly. Otherwise, please understand that such information as this should be posted in your profile feed post.
22nd Jul 2023, 1:27 PM
Brian
Brian - avatar
+ 3
Leeroy Mokua perhaps I misinterpreted the post. It appears to me as an explanation of how to use the write function. There is an example of how to call it and then the OP directs where to find more information. Somehow the question is not apparent to me, sorry if I missed the mark!
22nd Jul 2023, 3:04 PM
Brian
Brian - avatar
+ 2
Brian He is asking a programming question.
22nd Jul 2023, 1:39 PM
Leeroy Mokua
Leeroy Mokua - avatar
+ 2
Brian and Leeroy Mokua you are both right. At first glance the way the question is asked could lead someone to assume that they are only providing an answer. Perhaps if they were to ask, "How does the write function work?" then it would cause less confusion.
22nd Jul 2023, 6:25 PM
Chris Coder
Chris Coder - avatar
+ 1
Looks like I hit it on the mark. This Profile feed post clarifies the intent. https://www.sololearn.com/post/1739960/?ref=app
22nd Jul 2023, 6:58 PM
Brian
Brian - avatar