0

In the pset3, we need to make a Makefile to compile for generate.c and find.c files. In this case, the output of the generate.c file is piping to the find.c file. Would anyone help me with this? Thanks.

1

Sorry for my English in advance. If I understood you right, please let me explain. Let's say you want to pipe 1000 values generated by program "generate" to program "find".

  1. You are going to need to compile the programs first.

  2. To compile them easier not using clang, but with typing "make" command to terminal you may edit Makefile, which includes *.c file names you want to compile and *.h file names of libraries or "helpers" you are using. Actually Makefile hold short commands you want your terminal to understand. For instance you can assign that if you type "clean" in terminal it will delete both find and generate programs, and it means you don't need to type rm -f *.o a.out core find generate". Or if you type "make find" it will mean "execute command": clang -ggdb3 -O0 -std=c11 -Wall -Werror -o find find.c helpers.c -lcs50 -lm (So that you don't have to type that long message to terminal window each time you want to compile the program).

    After you compiled....

  3. Than you need to type in console(terminal) with pipe sign(|): ./generate 1000 | ./find 42

Alternatively, you can use another command, like "rederict" in terminal window:

./generate 1000 > numbers.txt

Hope it answers your question. If yes, please tick this answer on the left. If not, please comment!

2
  • Thank you for you respond. I misunderstood what they ask me to do. I thought there is a way to pipe an output of one file into another file by writing code in the Makefile file. Anyway thank you for your time. – Katie Ngo Apr 11 '16 at 19:36
  • But do we actually have to use Makefile like ./Makefile I then have the following output : bash: ./Makefile: Permission denied. Or does it solely holds short commands you want your terminal to understand and isn't an exec file? – Revolucion for Monica Sep 20 '16 at 15:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .