I have an unsigned char* type and want to assign it an integer value. How can I do it in C?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Just do it, with an appropriate cast:
This does exactly what you asked for, it assigns an integer value to a pointer to
unsigned char. This is not a very useful thing to be doing, but that’s how you do it.Of course there’s no requirement (that I’m aware of) that this is even possible; your architecture’s idea of a pointer might not support this, in which case I guess the compiler will tell you.