mirror of
https://github.com/krislamo/knrc.git
synced 2024-11-10 00:30:35 +00:00
Compare commits
7 Commits
fe248c5a30
...
93acdbe7e9
Author | SHA1 | Date | |
---|---|---|---|
93acdbe7e9 | |||
6bf093f44f | |||
3512ae49ab | |||
72093b7232 | |||
979467565f | |||
7099cc732e | |||
dcdc220259 |
12
04-file-copying.c
Normal file
12
04-file-copying.c
Normal file
@ -0,0 +1,12 @@
|
||||
#include <stdio.h>
|
||||
|
||||
/* Exercise 1-6 and 1-7 */
|
||||
int main()
|
||||
{
|
||||
int c;
|
||||
|
||||
printf("EOF = %d\n", EOF);
|
||||
|
||||
while (c = getchar() != EOF)
|
||||
printf("c = %d\n", c);
|
||||
}
|
10
05-char-counting.c
Normal file
10
05-char-counting.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
double nc;
|
||||
|
||||
for (nc = 0; getchar() != EOF; ++nc)
|
||||
;
|
||||
printf("%.0f\n", nc);
|
||||
}
|
21
06-line-count.c
Normal file
21
06-line-count.c
Normal file
@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int c, b, t, n;
|
||||
|
||||
b = 0;
|
||||
t = 0;
|
||||
n = 0;
|
||||
while ((c = getchar ()) != EOF) {
|
||||
if (c == ' ')
|
||||
++b;
|
||||
if (c == '\t')
|
||||
++t;
|
||||
if (c == '\n')
|
||||
++n;
|
||||
}
|
||||
printf("blanks = %d\n", b);
|
||||
printf("tabs = %d\n", t);
|
||||
printf("newlines = %d\n", n);
|
||||
}
|
11
Makefile
11
Makefile
@ -1,4 +1,4 @@
|
||||
all: hello mathvars c2f
|
||||
all: hello mathvars c2f input count countlines
|
||||
|
||||
hello: 01-hello-world.c
|
||||
gcc -o ./bin/01-helloworld 01-hello-world.c
|
||||
@ -9,5 +9,14 @@ mathvars: 02-vars-and-math.c
|
||||
c2f: 03-celsius-to-fahrenheit.c
|
||||
gcc -o ./bin/03-c2f 03-celsius-to-fahrenheit.c
|
||||
|
||||
input: 04-file-copying.c
|
||||
gcc -o ./bin/04-input 04-file-copying.c
|
||||
|
||||
count: 05-char-counting.c
|
||||
gcc -o ./bin/05-count 05-char-counting.c
|
||||
|
||||
countlines: 06-line-count.c
|
||||
gcc -o ./bin/06-line-count 06-line-count.c
|
||||
|
||||
clean:
|
||||
$(RM) ./bin/*-*
|
||||
|
Loading…
Reference in New Issue
Block a user