string reading_lev(int a, int b, int c)
{
float L = (a / b) * 100;
float S = (c / b) * 100;
float index = 0.0588 * L - 0.296 * S - 15.8;
if (round(index) <= 16 && round(index) >= 1)
{
string val = printf("Grade %f", index);
}
else if (round(index) > 16)
{
string val = printf("Grade 16+");
}
else
{
string val = printf("Before Grade 1");
}
return val
}
The error is in the first if block. There are cs50 libraries involved.
error: incompatible integer to pointer conversion initializing 'string' (aka 'char *') with an expression of type 'int' [-Werror,-Wint-conversion]
string val = printf(...)
?printf
returns anint
, you need to allocate space and then use snprintf to return a string. – David Ranierival
only exists until the closing brace}
, so thereturn
should also be generating an error. – user3386109;
in return statement, too. – Sourav Ghosh