bare bones version of wc

This commit is contained in:
qorg11 2020-06-16 18:52:17 +02:00
parent e4c35b7d88
commit 971e32a781
No known key found for this signature in database
GPG Key ID: 343FC20A4ACA62B9
1 changed files with 20 additions and 0 deletions

20
src/wc.c Normal file
View File

@ -0,0 +1,20 @@
#include <stdio.h>
int
main(void)
{
char c;
int newlines = 0, spaces = 0, bytes = 0;
while((c = getchar()) != EOF)
{
bytes++;
if(c == '\n')
newlines++;
if(c == ' ')
spaces++;
}
printf("%i %i %i\n",newlines,spaces,bytes);
return 0;
}