Skip to content

Commit

Permalink
Language.
Browse files Browse the repository at this point in the history
  • Loading branch information
janpgit committed Apr 7, 2024
1 parent 14eaa3e commit 53e237a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions modules/err.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ Instead of writing:

```C
if (error) {
fprintf(stderr, "Error occured: %s\n", strerror(errno));
fprintf(stderr, "Error: %s\n", strerror(errno));
exit(1);
}
```

Use the following:
Use the following. It will append ": " string and then the error message
itself, based on the value of `errno`.

```C
if (error)
err(1, "Error occured: ");
err(1, "Error");
```
- Notice that a newline is inserted automatically at the end of the error
Expand Down

0 comments on commit 53e237a

Please sign in to comment.