printf.c 686 B

1234567891011121314151617181920212223
  1. /* SPDX-License-Identifier: BSD-3-Clause */
  2. /*
  3. * Copyright (C) 2022, 2023 Ferass El Hafidi <vitali64pmemail@protonmail.com>
  4. */
  5. #include <unistd.h>
  6. #include <stdio.h>
  7. #include <errno.h>
  8. #define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */
  9. #define REQ_ERRPRINT /* Require print_usage() from ../common/common.h */
  10. #define DESCRIPTION "Write formatted strings to standard output."
  11. #define OPERANDS "format [string]"
  12. #include "../common/common.h"
  13. int main(int argc, char *const argv[]) {
  14. if (argc == 1) {
  15. print_usage(argv[0], DESCRIPTION, OPERANDS, VERSION);
  16. return 1;
  17. }
  18. printf(argv[1], argv[2] ? argv[2] : "");
  19. return errprint(argv[0], NULL, errno);
  20. }