Getting error message at compile.

helpers.c:17:18: error: non-object type 'int (string)' (aka 'int (char *)') is not assignable duration = numerator;

My code is as follows:

int duration(string fraction)
int numerator;
int denominator;
numerator = atoi fraction[0];
denominator = atoi fraction [2];

if (denominator == 8)
    duration = numerator;
else if (denominator !== 8)
    duration = (numerator * (8 / denominator));

If duration is defined as an int and numerator is defined as an int, why am I getting the error? There are more errors but they cascade from this (I think).


I assume that this problem lies in this:

duration = ...   ;

The issue is that duration is a function name, not a variable that can have a value assigned to it. Also it is not "defined" as an int, it is defined as a function that returns an int. Based on the design of your function, you need to use an int var with a different name and then return that value to the calling function.

A review of functions and the use of the keyword return would be of great benefit to you now.

There may be other issues, but that's for another question. ;-)

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .