gpt4 book ai didi

C++ sscanf_s 值不正确

转载 作者:行者123 更新时间:2023-11-28 03:02:06 37 4
gpt4 key购买 nike

我像这样使用 sscanf_s:

    double a = 0;
double b = 0;
sscanf_s(elements[1].c_str(),"<%d,%d>", &a, &b);
complex<double> first(&a,&b);

但是当我输入 1,2 时,我得到的值是 4.5 和 1.9。

为什么会出错?

最佳答案

您需要使用正确的转换说明符。 %d 用于 int%lf 用于double

关于C++ sscanf_s 值不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20528092/

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