Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!know!sdd.hp.com!wuarchive!mit-eddie!bloom-beacon!eru!hagbard!sunic!nuug!nososl!olav From: olav@nososl.UUCP (Olav Eide) Newsgroups: comp.unix.internals Subject: Re: System() function Message-ID: <81@nososl.UUCP> Date: 23 Oct 90 17:48:59 GMT References: <24826@adm.BRL.MIL> Reply-To: olav@nososl.UUCP (Jan-Olav Eide) Organization: Nordic Offshore Systems A/S - Drilling Information Services Lines: 14 In article <24826@adm.BRL.MIL> vilva@csvax.csc.lsu.edu (Vilva Natarajan) writes: > >I am trying to do system("man cat | wc -c") in my program, and i need >to store the value returned by "wc" in a variable declared in my program. >I dont want to redirect it to a file and then read from the file. >Please advice. > Why not use the popen call ? fd = popen("man cat | wc -c","r"); fgets(line,LL,fd); sscanf(line,"%d",&your_variable); You should of course check the return values for popen and fgets