In your code
char itoa(num, intStr[10]);
return itoa;
tells the compiler that you declare a function called itoa
with specific signature, then you want to return (a pointer to) this function. Since you declared the return type as char
, the compiler doesn't like this.
It should rather look something like
char int2String(int num, char intStr[10]) {
char ch = itoa(num, intStr);
return ch;
}
i.e. call the function itoa
with given parameters, store its return value in a local variable of type char
, then return it. (The local variable could be inlined to simplify the code.)
Now this still does not make the compiler happy, since itoa
, although not part of the standard, is by convention declared to return char*
, and to take 3 parameters, not 2. (Unless you use a nonstandard definition if itoa
, that is.)
With the "standard" itoa
version, this modification should work (in theory at least - I have not tested it :-)
char* int2String(int num, char intStr[10]) {
return itoa(num, intStr, 10);
}