The perror and strerror functions that pull standard error descriptions come from the global variable, sys_errlist.
引出标准错误描述的perror和strerror函数来自sys_errlist全局变量。
It shows appropriate use of some system calls and library functions from c, including fopen, fclose, access, setvbuf, perror, strerror, and popen.
它演示了对一些系统调用和c库函数的适当使用,其中包括fopen、fclose、access、setvbuf、perror、strerror和popen。
When an error occurs in a system call, you can access and display a message corresponding to the error in at least one of two ways: by using either the perror or the strerror function.
当系统调用中出现错误时,您至少可以用以下两种方式的一种来访问和显示与该错误对应的消息:通过使用perror或strerror函数。
As you can see from the output (Listing 2), the perror function displays the string you pass to it, followed by a colon, a space, and then the textual representation of the current errno value.
正如您可以从输出(清单2)中看到的,perror函数显示了传递给它的字符串,后跟冒号、空格,接着是当前errno值的文字表示形式。
One detail you can't see from the output is that perror() writes its message to the standard error channel (stderr); the printf() call in Listing 1 is writing to the standard output channel (stdout).
您无法从输出中看到的一个细节是,perror() 将其消息写入标准错误通道 (stderr);清单1中的printf()调用将写入标准输出通道 (stdout)。
One detail you can't see from the output is that perror() writes its message to the standard error channel (stderr); the printf() call in Listing 1 is writing to the standard output channel (stdout).
您无法从输出中看到的一个细节是,perror() 将其消息写入标准错误通道 (stderr);清单1中的printf()调用将写入标准输出通道 (stdout)。
应用推荐