如何将uint8_t(SDL中的Uint8)转换为字符串?

时间:2011-10-24 16:54:15

标签: c++ c types casting sdl

(我刚刚搜索了一段时间之后回答了这个问题,所以我在这里提出并回答这个问题,因为它在需要的时候会在这里。有类似但不完全相同的问题。)

1 个答案:

答案 0 :(得分:0)

将其投放到int。这可以由stringstream消费,也可以转换为string使用。

其中colour是包含struct SDL_Color Uint8成员的uint8_t成员的stringstream ss << "[colour=" << (int)colour.r << ", " << (int)colour.g << ", " << (int)colour.b << "; light=" << light << "]"; ,解决方案是

{{1}}