gpt4 book ai didi

c - 将 int 传递给需要 char* 的函数

转载 作者:太空狗 更新时间:2023-10-29 11:33:37 25 4
gpt4 key购买 nike

我想将 int 传递给需要 char * 的函数。

函数头如下所示:

void swapEndian(char *pElement, unsigned int uNumBytes)

并使用 int 调用函数(我知道,这行不通..)

int numLine;
swapEndian(numLine, sizeof(int));

那么我必须对 numline 做些什么才能将它传递给这个函数?

最佳答案

听起来好像你只是想要:

swapEndian( (char*) &numLine, sizeof(int) );

关于c - 将 int 传递给需要 char* 的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13309139/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com