Reputation: 1
Ok so, i'm trying to covnert some number into others via function. The vector "tempc" contains 7 celsius numbers. The type "tempf" will contain fahrenheit. But i get this error in the title "error invalid conversion from 'float*' to 'int' [-fpermissive]". I'm new to programming , so i'm kinda really newbie. Sorry for the code but it's in italian
#include <iostream>
using namespace std;
//dichiarazione variabili e vettori
float tempc[7] = {23,25,22,19,18,20,16};
float tempf[7];
const int MAX_GRADI = 7;
//funzione conversione
int ConversioneInF ()
{
for (int i=0;i<MAX_GRADI;i++)
tempf[i]=(9/5)*tempc[i]+32; //C in F
return tempf;
}
int main ()
{
ConversioneInF();
for (int i=0;i<MAX_GRADI;i++)
cout<<"La temperatura in fahrenheit e' :"<<tempf[i]<<endl;
return 0;
}
Upvotes: 0
Views: 1742
Reputation: 86
void ConversioneInF ()
{
for (int i=0;i<MAX_GRADI;i++)
tempf[i]=(9.0/5.0)*tempc[i]+32;
}
Anyway, tempf is global, you don't need to return it.
Upvotes: 1
Reputation: 36
In your function ConversioneInf
you are returning tempf
.
This is a float-array, which in c++ is a pointer to float (float*
)
This type cannot be converted to the specified return type int
.
As you are not using the return value, just change it to void:
void ConversioneInF ()
Upvotes: 2