aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqorg11 <qorg@vxempire.xyz>2020-08-29 00:20:17 +0200
committerqorg11 <qorg@vxempire.xyz>2020-08-29 00:20:17 +0200
commitea00641408b50b763f1d0a2d0d42ef225b554636 (patch)
tree9b9342171049c6e5f92a56c4f6139c4f48c18379
parent21718a0a616767b51b2a1e039b877ed706d466ef (diff)
downloadk9core-ea00641408b50b763f1d0a2d0d42ef225b554636.tar.gz
k9core-ea00641408b50b763f1d0a2d0d42ef225b554636.zip
wc prints the filename
-rw-r--r--src/wc.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/wc.c b/src/wc.c
index 355e740..b9b48d6 100644
--- a/src/wc.c
+++ b/src/wc.c
@@ -11,7 +11,6 @@ struct wc_values
int lines;
int bytes;
int words;
- char *filename;
};
struct wc_values
@@ -42,7 +41,7 @@ wc(FILE *file)
return foobar;
}
void
-print_values()
+print_values(const char*filename)
{
if(show_bytes && show_lines && show_words)
printf("%i %i %i",
@@ -58,7 +57,7 @@ print_values()
if(!show_bytes)
printf("%i ",data.bytes);
}
- printf("\n");
+ printf(" %s\n",filename);
}
int
main(int argc, char *argv[])
@@ -89,7 +88,7 @@ main(int argc, char *argv[])
if(optind == argc)
{
data = wc(stdin);
- print_values();
+ print_values("stdin");
}
else for(int i = optind; i<argc; i++)
{
@@ -97,7 +96,7 @@ main(int argc, char *argv[])
data = wc(stdin);
else
data = wc(fopen(argv[i],"r"));
- print_values();
+ print_values(argv[i]);
}
return 0;
}