I was reading What is uintptr_t data type but still I'm unable to understand uintptr_t
here as
- what purpose it serve by first converting temporarily char array type to
unsigned long int
type and then converting back tochar*
type.
Consider the below code snapshot
strncpy(pCfgMgr->mGlobalCfg.grMap[index].userName,
(char *)(uintptr_t) grParams.peerUsrName, 16); /*index is 0 */
where userName
in the pCfgMgr->mGlobalCfg.grMap[index].userName
is nothing but a char array declared as
char userName[MAX_USERNAME_LENGTH]; /* MAX_USERNAME_LENGTH is 16 */
And peerUsrName
in the grParams.peerUsrName
is also a char array declared as
char peerUsrName[16];
The thing which I didn't got is that what uintptr_t
makes the difference while copying, which is nothing but alias name of unsigned long int
. I am curious to know what the developer was thinking while using uintptr_t
here & is it recommended ?
Though without uintptr_t
above strncpy()
statement produces the same output.
All helps appreciated wholeheartedly.