J
Johan Tibell
I've written a piece of code that uses sockets a lot (I know that
sockets aren't portable C, this is not a question about sockets per
se). Much of my code ended up looking like this:
if (function(socket, args) == -1) {
perror("function");
exit(EXIT_FAILURE);
}
I feel that the ifs destroy the readability of my code. Would it be
better to declare an int variable (say succ) and use the following
structure?
int succ;
succ = function(socket, args);
if (succ == -1) {
perror("function");
exit(EXIT_FAILURE);
}
What's considered "best practice" (feel free to substitute with: "what
do most good programmers use")?
sockets aren't portable C, this is not a question about sockets per
se). Much of my code ended up looking like this:
if (function(socket, args) == -1) {
perror("function");
exit(EXIT_FAILURE);
}
I feel that the ifs destroy the readability of my code. Would it be
better to declare an int variable (say succ) and use the following
structure?
int succ;
succ = function(socket, args);
if (succ == -1) {
perror("function");
exit(EXIT_FAILURE);
}
What's considered "best practice" (feel free to substitute with: "what
do most good programmers use")?