所以我知道如何在 C# 中做到这一点,但不是 C++。我正在尝试将给予者用户输入解析为双精度(稍后进行数学运算),但我是 C++ 新手并且遇到了麻烦。帮助?
C#
public static class parse
{
public static double StringToInt(string s)
{
double line = 0;
while (!double.TryParse(s, out line))
{
Console.WriteLine("Invalid input.");
Console.WriteLine("[The value you entered was not a number!]");
s = Console.ReadLine();
}
double x = Convert.ToDouble(s);
return x;
}
}
C++?? ? ?