Hi,
I am calling a function which is declared as follows:
typedef char HMI_CHAR;
typedef UINT32 LANG_SID_T;
HmLanguage1GetString(LANG_SID_T p_sid, HMI_CHAR * p_str_dest_P, UINT8 p_req_length, UINT8 p_cur_language_U8);
Now i am calling the above function as below:
HMI_CHAR *static_string;
UINT8 replace_char = 0;
HmLanguage1GetString(0xB4C, &static_string, 12, replace_char);
Actually i the API which i am calling will return a string in the static_string variable which is nothing but a destination pointer.
What i want to know is am i passing the parameters correctly?
And one more thing i want know is after getting the string which is returned by the API, how can i store the same in an array one character after the other?
Note: This is pure C coding. Reply needed ASAP.
Loading
VulpesPosted Dec 5, 2011, 1:47 PM
Sam HobbsPosted Dec 5, 2011, 2:20 PM
p_str_dest_P[1] = '*';
}
int _tmain(int argc, _TCHAR* argv[])
{
HMI_CHAR static_string[256] = "initial";
UINT8 replace_char = 0;
puts(static_string);
HmLanguage1GetString(0xB4C, static_string, 12, replace_char);
puts(static_string);
}
Given the following:
The following two lines are equivalent:
s[1] = '*';
In any good book about C the first chapter about pointers will explain that and even most bad books about C will.
Karthik AgarwalPosted Dec 5, 2011, 12:20 PM
VulpesPosted Dec 5, 2011, 12:03 PM
Also, you need to initialize it to create a buffer big enough for the string that is going to be returned.
If, say, 256 bytes will be big enough, I'd suggest:
HMI_CHAR static_string[256];
UINT8 replace_char = 0;
HmLanguage1GetString(0xB4C, static_string, 12, replace_char);
static_string is (effectively) already a char array so you can index it to get each character. So to get the first one:
HMI_CHAR first = static_string[0];