Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/159.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ ‘;设置精度’;不是‘;标准&x2019;_C++_String - Fatal编程技术网

C++ ‘;设置精度’;不是‘;标准&x2019;

C++ ‘;设置精度’;不是‘;标准&x2019;,c++,string,C++,String,错误: 代码: #包括 #包括 #包括 int main() { //将'lat'、'lons'和'vehicleId'转换为字符串。 浮点数LAT=2.2; 浮点数lng=2.3; 浮动车辆ID=1.0; 标准::stringstream floatToStringLat、floatToStringLng、floatToStringVehicleId; floatToStringLat您需要为和包含标题。这些引用告诉您要包含哪个标题。不包含string.h…您的意思是string还是cstri

错误:

代码:

#包括
#包括
#包括
int main()
{
//将'lat'、'lons'和'vehicleId'转换为字符串。
浮点数LAT=2.2;
浮点数lng=2.3;
浮动车辆ID=1.0;
标准::stringstream floatToStringLat、floatToStringLng、floatToStringVehicleId;

floatToStringLat您需要为和包含标题
。这些引用告诉您要包含哪个标题。

不包含
string.h
…您的意思是
string
还是
cstring
?对于
std::numeric\u limits
btw,您需要
。记住,您可以找到通过在C++引用中查看它们:
~> g++ ssstring.cpp
ssstring.cpp: In function ‘int main()’:
ssstring.cpp:12:31: error: ‘setprecision’ is not a member of ‘std’
ssstring.cpp:12:52: error: ‘numeric_limits’ is not a member of ‘std’
ssstring.cpp:12:74: error: expected primary-expression before ‘float’
ssstring.cpp:13:30: error: ‘setprecision’ is not a member of ‘std’
ssstring.cpp:13:51: error: ‘numeric_limits’ is not a member of ‘std’
ssstring.cpp:13:73: error: expected primary-expression before ‘float’
ssstring.cpp:14:28: error: ‘setprecision’ is not a member of ‘std’
ssstring.cpp:14:49: error: ‘numeric_limits’ is not a member of ‘std’
ssstring.cpp:14:71: error: expected primary-expression before ‘float’
anisha@linux-trra:~>
#include <sstream>
#include <iostream>
#include <string.h>

int main ()
{
    // Convert `lat`, `lons`, and `vehicleId` to string.
    float selectedPointLat = 2.2;
    float selectedPointLng = 2.3;
    float vehicleId        = 1.0;

    std :: stringstream floatToStringLat, floatToStringLng, floatToStringVehicleId;

    floatToStringLat       << std :: setprecision (std :: numeric_limits<float> :: digits10 + 1); floatToStringLat  << selectedPointLat;
    floatToStringLng       << std :: setprecision (std :: numeric_limits<float> :: digits10 + 1); floatToStringLng << selectedPointLng;
    floatToStringVehicleId << std :: setprecision (std :: numeric_limits<float> :: digits10 + 1); floatToStringVehicleId << vehicleId;

}