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;
}