lundi 2 février 2015

no known conversion from 'char [30]' to 'int' [on hold]

I'm in trouble compiling this c code on osx.


I have a simple function that must return char:



int level=50;

char *FOrFL(int altitude)
{
char* message = new char[40];
if(altitude/100 >= level){
sprintf(message, "the level is %i", altitude/100);
}else{
sprintf(message, "%i level", altitude);
}
return message;
}


compiling in osx I get this error:


candidate function not viable: no known conversion from 'char [30]' to 'int' for 1st argument


I need to return char because this function are called within a pre-existent, complex sprintf chain.


Reading some posts I figure out that is a problem with new c++11 standard. But I can't find any solution, there are few posts discussing this problem but I did not found any solution that fit my case.


Aucun commentaire:

Enregistrer un commentaire