I don’t get this part. How can I do it if I’m not allowed to use global variables? Example:
main()
{ int z;
function1(&z);
}
function1(int *x)
{
function2(&x);
}
function2(int *number)
{
++(*number);
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When
function1callsfunction2, just pass inx, not&x.&xwill passfunction2a pointer to a pointer to anint, but it is declared to only take a pointer to anint.Other issues:
zshould be initialized, and the functions should either have forward declarations, are declared abovemain.mainshould be declared to return anint, and return0on success. And as noted in the other answer, your other functions also need return types.