Add -n flag to echo
This commit is contained in:
parent
79ec3add72
commit
2214494a77
|
@ -1,13 +1,17 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int nflag;
|
||||
if(strcmp(argv[1], "-n") == 0)
|
||||
nflag = 1;
|
||||
++argv;
|
||||
while(*argv) {
|
||||
(void)fputs(*argv, stdout); // Print argv
|
||||
if(*++argv) putchar(' '); // If multiple things in argv, print a space between them.
|
||||
}
|
||||
putchar('\n');
|
||||
if(nflag) putchar('\n');
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue