Another stupid newbie question ...
I'm used to Pascal/Delphi, which works well with strings.
I have written a function to return to me the hardware platform my app is running on. The function declaration looks like this:
Code:
char* INIT_GetHWType(void)
{
char* HWType;
do stuff
do more stuff
return HWType;
}
Somewhere else, I'd like to call this function to find out what I have got. So I do this:
Code:
{
WORD wTermStatus;
WORD wBankResult;
BYTE szPin[5];
Storage_Init();
if (INIT_GetHWType == "xyz")
{
//Set display size options here
}
etc., etc., etc.
This gives me a warning : Warning ..\source\init.c 45: Nonportable pointer comparison in function INIT_StartApp()
So I try the following:
Code:
{
WORD wTermStatus;
WORD wBankResult;
BYTE szPin[5];
char* HWType;
Storage_Init();
HWType = INIT_GetHWType;
if ( HWType== "xyz")
{
//Set display size options here
}
etc., etc., etc.
And this gives a compiler error.
Error ..\source\init.c 46: Cannot convert 'char * (*)()' to 'char *' in function INIT_StartApp()
OK, so I've googled this, and vaguely understand what the problem is. What I do not understand is: How do I assign the result of a function (which returns a string) to a variable that contains a string?
In Pascal, I would do something like the following:
Code:
function MyFunction : string;
begin
do stuff
result := 'stuff';
end;
procedure Callfunction
var
astring : string;
begin
astring := MyFunction;
end;
How do I do the same or similar in C?