5, judgment on the return to the system call

xiaoxiao2021-03-06  87

----------------

Continue to the previous, for some system calls, such as opening files, I often see that many programmers do not do any judgment on FOPEN, they are directly used. Then find that the content of the file is not read, or you can't write it. Still judge:

FP = fopen ("log.txt", "a");

IF (fp == NULL) {

Printf ("Error: Open File Error / N");

Return False;

}

There are still many other, such as: Socket number returned by Socket, Malloc returned by Mall. Please judge what these system calls returned.

转载请注明原文地址:https://www.9cbs.com/read-107747.html

New Post(0)