9main (
int argc,
char *argv[])
15 printf (
"usage: cmp A B\n");
20 fd[0] =
open (argv[1]);
23 printf (
"%s: open failed\n", argv[1]);
26 fd[1] =
open (argv[2]);
29 printf (
"%s: open failed\n", argv[1]);
45 min_read = bytes_read[0] < bytes_read[1] ? bytes_read[0] : bytes_read[1];
49 for (i = 0; i < min_read; i++)
52 printf (
"Byte %d is %02hhx ('%c') in %s but %02hhx ('%c') in %s\n",
59 if (min_read < bytes_read[1])
60 printf (
"%s is shorter than %s\n", argv[1], argv[2]);
61 else if (min_read < bytes_read[0])
62 printf (
"%s is shorter than %s\n", argv[2], argv[1]);
65 printf (
"%s and %s are identical\n", argv[1], argv[2]);
int main(int argc, char *argv[])
cat.c
int printf(const char *format,...)
Writes formatted output to the console.
int open(const char *file)
int read(int fd, void *buffer, unsigned size)
#define EXIT_SUCCESS
Typical return values from main() and arguments to exit().
#define EXIT_FAILURE
Unsuccessful execution.