Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

incompatible pointer to integer conversion initializing 'int' with an expression of type 'int (void)'

#include <cs50.h>
#include <stdio.h>
int get_cents(void);
int calculate_quarters(int cents);


int main(void)
{

    //Ask how many cents the customer is owed
    int cents = get_cents;

    // Calculate the number of quarters to give the customer
    int quarters = calculate_quarters(cents);
    cents = cents - quarters * 25;

}

int get_cents(void)
{
    int cents;
    do
    {
      cents = get_int("Changed owed: ");
    }

    while (cents < 0);
    return cents;
}

int calculate_quarters(int cents)
{
 return 0;
}

incompatible pointer to integer conversion initializing ‘int’ with an expression of type ‘int (void)’ [-Werror,-Wint-conversion]
int cents = get_cents;

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

int cents = get_cents;

Here you are not really calling the function get_cents. You have to use parantheses like this:

int cents = get_cents(...);

The error is because get_cents is a pointer to that function and you are assigning the pointer to the int variable.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading