This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center
                            
                        
                    
                
                                6年前关闭。
            
                    
我想知道是否在这里进行铸造是最好的解决方案:

这是函数原型:

void function(unsigned char * data)


这就是我打算使用它的方式(从中读取nSize):

unsigned int nSize = 15;

function( (unsigned char*) &nSize);

最佳答案

假设函数原型是固定不变的,并且nSize必须为int,是的,对我来说似乎正确。

关于c++ - 在这里类型转换最好的解决方案? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16934015/

10-12 14:52