Я не могу запустить эту функцию под названием 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
Что мне не хватает в разыменовании и моем синтаксисе ??