dongtaogu8510 2016-07-25 18:09
浏览 387

将go字符串转换为c字符串

In a program, I have a function that takes in a string argument, and returns a string in which len(resultString) could potentially be 4 * len(argumentString). This is because I am using Cgo with a C-file that I have imported into my project, and this C function requires a char * that is 4 times the original length of a string.

Is there an 'efficient' way of initializing and converting a go string to a C string? Because right now I am initializing a byte array in Go, and then stringing that, and then calling C.CString on that string. This ultimately is causing some performance issues if the length of the string is large enough. Thanks!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 Revit2020下载问题
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
    • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数
    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 如何在炒股软件中,爬到我想看的日k线