Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pointer function arguments #89

Closed
wants to merge 3 commits into from
Closed

Pointer function arguments #89

wants to merge 3 commits into from

Conversation

Satantago
Copy link

@Satantago Satantago commented Oct 6, 2022

Please fill in this pull request template before submitting

1. This pull request resolves #26

2. Description

This tutorial explains function pointers as arguments in C. It first describes what a function pointer is and then shows how to pass a function pointer as a parameter to a function.

3. Fill in checklist by marking [x]

  • I've read the CONTRIBUTING.md
  • I was assigned to this issue
  • My code is formatted using required linting
  • I've run my code locally and checked it works

@funbeedev funbeedev linked an issue Oct 7, 2022 that may be closed by this pull request
@funbeedev
Copy link
Member

Thanks for the PR :) It will be reviewed in due course.

Copy link
Member

@sabderemane sabderemane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I made some suggestions :)


e.g:
float (*add)(); this is a valid declaration for the function pointer
float *add(); this is an illegal declaration for the funciton pointer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
float *add(); this is an illegal declaration for the funciton pointer
float *add(); this is an illegal declaration for the function pointer

4. We assign Function2 to FunctionPointer: FunctionPointer = Function2
5. We then call function F1 with FunctionPointer as a parameter.

We shall see an illustration of this in the example below.
------------------------------------------------------------------------------------
*/

// Code here explaining concept with comments to guide
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Code here explaining concept with comments to guide

Challenge:
1. Write a function that prints "I love pointers!"
2. Declare a corresponding function pointer and assign the previous function to it.
3. Write a second function with the correspoing function pointer type as parameter.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
3. Write a second function with the correspoing function pointer type as parameter.
3. Write a second function with the corresponding function pointer type as parameter.

@funbeedev
Copy link
Member

Adding hacktoberfest-accepted label. Will review and merge later on.

@Satantago Satantago closed this by deleting the head repository Dec 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pointer-function-arguments C tutorial
3 participants