1
我写了一个C程序。 (页面底部的问题)我可以提供实际的代码,但我不认为有必要回答这个问题。c编程理解strace -o t.txt ./a.out
Used a while loop with fgets to get sizeof line
Assigned that fgets to line[255] in the fgets
Assigned the line to a char* (inside the loop)
Printf the char* (also inside the loop)
C程序的输出作为预期。
我使用strace -o x.txt ./a.out来查看幕后发生了什么。
我看到以下内容:(当然还有很多更断章取义高于/低于它,我不明白)
read(3, "text\nMore text\nEven more text"..., 4096) = 72
write(1, "text\n",5) = 5
... more of the write() = #
read(3, "", 4096) = 0
close(3)
问:
我得到的
write(1=stdout, "text to print", #of char)
或者是这个字节数?我不明白
read(3, "", 4096) = 0
我知道0=stdin
,1=stdout
,2=stderr
,不知道是什么3种手段 - 也许这是什么文件? 我不知道为什么它正在做另一个读取,我假设4096是什么缓冲区大小? 我最好的猜测是,因为它说= 0,因为它的EOF?字符
你已经打开的文件的
3似乎是用来引用文件的数字?读(3,x,x)并关闭(3)? – Kairan