system() function ?
글쓴이: 익명 사용자 / 작성시간: 목, 2002/07/18 - 11:18오후
I want to get result value system func.
i.e.
system( " wc -l < a.sam | awk '{print $1}' )
this system function results in integer value. ( = line count of sam file )
How can I get this value? ( using gets? ,,, help me )
-- I want to write in hangul, but I can't now in this system. sorry.
Forums:
Re: system() function ?
use popen...^^
show you example ..
#include
#include
main()
{
char *cmd = "/usr/bin/ls *.c";
char buf[BUFSIZ];
FILE *ptr;
if ((ptr = popen(cmd, "r")) != NULL)
while (fgets(buf, BUFSIZ, ptr) != NULL)
(void) printf("%s", buf);
return 0;
}
댓글 달기