Hello world
I have a simple question, taking output of one file, and using it as input for another. I've been googling around for a long time, found lots of code but it doesn't do what I'm looking for, probably because I'm searching wrong.. I have 4 different scripts to simplify my program, but I need the output from them all.
E.g. (this is not my real program, just a small example with same concept)
---------------- file1.c ------------------
Code:
int main(void) {
char* charArray;
fgets (charArray, 2, stdin); //get user chars input
printf("%c", charArray);
}
---------------- file2.c ------------------
Code:
int main(int argc,char *argv[]) { //this program takes input from command line
printf ("%s", argv[1])
}
So yeah, that is quick example.
Running file1.c, at fgets, input, you enter: abc .. And it prints it out on terminal
Running file2.c, ./file2.o abc
So the output of file1.o, and automatically use it in file2.o's input argument, without me having to do 2 separate executions on 2 files.
So now I will explain my proper situation I'm in, (I've got all the code working for the inside of the file (there is a lot of code in each file so I need to keep them separate or I get confused like hell), however I want to automate all the executions instead of me manually typing 4 separate commands into CLI. So after waiting until a file has executed, then using the output of that file, as the arg (input) for the next file):
./file4.o > output.txt //copies entire OUTPUT block of text into file "output.txt"
./file3.o .. reads file "output.txt", and at end printf string
./file2.o .. reads file3.o OUTPUT (string), and printf another string,
./file1.o .. reads file2.o OUTPUT (string), and does what I need it to do
P.s. in my current code, by OUTPUT I mean printf, but I'm guessing you guys will not printf the OUTPUT, instead pipe it into the next files args somehow
P.s.s. I can't directly pipe file4.o OUTPUT into file3.o INPUT, as the output.txt it is very very big, and my file3.o is coded with using a text file.
Sorry for the long winded question. I hope you understand it