I’m new to c, and this code confuses me:
pid_t getpid(void)
if what follows the type identifier pid_tis a variable (It’s a variable declaration), but instead it’s a function call getpid(), I don’t know what why this function call is used.
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.
You’re right that
pid_tis a type identifier, but it’s not a variable.pid_tis the return type of the functiongetpid().Every function in C has a return type. Functions are declared like this:
returntype functionName(arguments)For example,
int main(int argc, const char * argv[])returns anintand takes two arguments.