# How to convert Int to uint8?

**URL:** <https://forums.unrealengine.com/t/how-to-convert-int-to-uint8/413453>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [December 31, 2017, 8:20am UTC](https://forums.unrealengine.com/t/how-to-convert-int-to-uint8/413453 "2017-12-31T08:20:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juvarunst](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Juvarunst](https://forums.unrealengine.com/u/Juvarunst)\
**Post date:** [December 31, 2017, 8:20am UTC](https://forums.unrealengine.com/t/how-to-convert-int-to-uint8/413453/1 "2017-12-31T08:20:13Z")

</div>

how to convert Int to uint8?

I try to do this:

int test\_data = 123456;

uint8\* send\_data;

send\_data = (uint8\*)test\_data;

But send\_data does not seem to be 123456

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_49a519741](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_49a519741](https://forums.unrealengine.com/u/anonymous_user_49a519741)\
**Post date:** [December 31, 2017, 8:48am UTC](https://forums.unrealengine.com/t/how-to-convert-int-to-uint8/413453/2 "2017-12-31T08:48:39Z")

</div>

`send_data = (uint8*) &test_data;`

Note the & symbol. It means “address of”. Pointers need the address of the variable. You were assigning the value of the int to the pointer. Then when you want the value being pointed to by a pointer, you use the \* symbol:

`int newInt = *(int*) test_data;`

Also keep in mind that int and uint8 are not the same size so you will need to send “sizeof(int)” bytes of data.

---

<div class="post-metadata">

**Author:** ![Juvarunst](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Juvarunst](https://forums.unrealengine.com/u/Juvarunst)\
**Post date:** [December 31, 2017, 10:00am UTC](https://forums.unrealengine.com/t/how-to-convert-int-to-uint8/413453/3 "2017-12-31T10:00:25Z")

</div>

Thank you, I’m trying

---

<div class="post-metadata">

**Author:** ![Juvarunst](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Juvarunst](https://forums.unrealengine.com/u/Juvarunst)\
**Post date:** [December 31, 2017, 10:03am UTC](https://forums.unrealengine.com/t/how-to-convert-int-to-uint8/413453/4 "2017-12-31T10:03:25Z")

</div>

This is the code I’m testing：

```
int test_data = 123456;
uint8* send_data = (uint8*)&test_data;
int32 sent = 0;
Socket->Send(send_data, sizeof(int), sent);
```

---

<div class="post-metadata">

**Author:** ![Juvarunst](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Juvarunst](https://forums.unrealengine.com/u/Juvarunst)\
**Post date:** [December 31, 2017, 10:23am UTC](https://forums.unrealengine.com/t/how-to-convert-int-to-uint8/413453/5 "2017-12-31T10:23:47Z")

</div>

It works, thanks 🙂
