File tree 2 files changed +48
-0
lines changed
2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ ALLPROG =sieve
2
+ all : $(ALLPROG )
3
+ O ?= -O2
4
+
5
+ include ../common/rules.mk
6
+
7
+ % : % .o $(BUILDSTAMP )
8
+ $(CC ) $(LDFLAGS ) -o $@ $<
9
+
10
+ % .o : % .c $(BUILDSTAMP )
11
+ $(CC ) $(CPPFLAGS ) $(CFLAGS ) $(DEPCFLAGS ) $(O ) -o $@ -c $<
12
+
13
+ clean :
14
+ rm -f $(ALLPROG ) * .o
15
+ rm -rf $(DEPSDIR ) * .dSYM
16
+
17
+ .PHONY : all clean
Original file line number Diff line number Diff line change
1
+ #include <sys/stat.h>
2
+ #include <sys/types.h>
3
+ #include <sys/wait.h>
4
+ #include <assert.h>
5
+ #include <errno.h>
6
+ #include <fcntl.h>
7
+ #include <stdio.h>
8
+ #include <stdio_ext.h>
9
+ #include <stdlib.h>
10
+ #include <string.h>
11
+ #include <unistd.h>
12
+
13
+ // Fork a child, who reads from my stdout.
14
+ // Then, read from standard in.
15
+ // Output the first thing read to stderr
16
+ // Then write everything after it to standard out, removing anything that
17
+ // is a multiple of that first value.
18
+ int main (int argc , char * argv []) {
19
+ (void )argc ;
20
+ (void )argv ;
21
+
22
+ int val ;
23
+
24
+ // Read first value and output to stderr
25
+ if (scanf ("%d " , & val ) != 1 )
26
+ exit (1 );
27
+ fprintf (stderr , "%d " , val );
28
+
29
+ // TODO: Read values from your standard input and write them to
30
+ // your standard output if they are not a multiple of val.
31
+ }
You can’t perform that action at this time.
0 commit comments