I'm trying to develop a function that could return different data type e.g. byte, word, dword etc.
How do i get started on doing this?
A simple example would be something like this:-
Code:
void multi_read(int feature_id)
{
/* Data type to be supported */
boolean result0;
byte result1;
word result2;
dword result3;
int64 result4;
byte result5[2][100];
switch(feature_id)
{
case 0:
/* Boolean */
/* Some processing */
result0 = TRUE;
return result0;
break;
case 1:
/* Byte */
/* Some processing */
result1 = 250;
return result1;
break;
case 2:
/* Word */
/* Some processing */
result2 = 40000;
return result2;
break;
case 3:
/* Dword */
/* Some processing */
result3 = 125000;
return result3;
break;
case 4:
/* Int64 */
/* Some processing */
result4 = 5000000;
return result4;
break;
case 5:
/* Array */
/* Some processing */
strcpy(result5[0],"Hello World!");
strcat(result5[0],"\0");
strcpy(result5[1],"My_Version_ID");
strcat(result5[1],"\0");
return &result5[1];
break;
default:
/* Some processing */
break;
}
return FALSE;
}
Thanks in advance for any ideas/guides.