KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I usually use pointers in the following manner char *ptr = malloc( sizeof(char) * 100 ); memset( ptr, 0, 100 ) ; strncpy( ptr, "cat" , 100 - 1 ); But this time instead of using "cat", I want to use it ASCII equivalent in hex. cat = 0x63, 0x61, 0x74, 0x00 I tried strncpy( ptr, "0x630x61" , 100 - 1 ); But it fails as expected. What is the correct syntax? Do I need to put a 0x00 too? For a moment lets forget about memset , now do I need to put a 0x00? Because in "cat" notation, a null is automatically placed. Regards
Tags (comma-separated)
Save Edits
Cancel