system("awk 'BEGIN {i=0;}$0 ~/^D/ { i++; printf "i";}END {}' out.txt");
I have used this line in my c++ code to count some lines in out.txt. it printing correct i value. now i need to use this i count value in c++. can any one help me to do this.
You need to use popen, instead of system.
see here: http://pubs.opengroup.org/onlinepubs/009696799/functions/popen.html
It's like a cross between fopen() and system(), it "returns" the output of the system call as a unix-style pipe, which is much like a FILE*.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With