エラーが発生せずに factorial() と呼ばれるこの関数を実行できないようです。
最初に があればinbuf = atoi(factorial(inbuf));
、gcc が吐き出しますが、
main.c:103: warning: passing argument 1 of ‘factorial’ makes integer from pointer without a cast
に変更するとinbuf = atoi(factorial(inbuf*));
、gccが吐き出し、
main.c:103: error: expected expression before ‘)’ token
関連コード:
int factorial(int n)
{
int temp;
if (n <= 1)
return 1;
else
return temp = n * factorial(n - 1);
} // end factorial
int main (int argc, char *argv[])
{
char *inbuf[MSGSIZE];
int fd[2];
# pipe() code
# fork() code
// read the number to factorialize from the pipe
read(fd[0], inbuf, MSGSIZE);
// close read
close(fd[0]);
// find factorial using input from pipe, convert to string
inbuf = atoi(factorial(inbuf*));
// send the number read from the pipe to the recursive factorial() function
write(fd[1], inbuf, MSGSIZE);
# more code
} // end main
逆参照と私の構文について何が欠けていますか??