我正在研究Bjarne Stroustrup的《编程-原理与实践》,这让我很费解(这只是11中的第2部分)。
import React, { Component } from 'react';
import { Navbar, NavbarBrand } from 'reactstrap';
import logo from './logo.svg';
import './App.css';
class App extends Component {
render() {
return (
<div className="App">
<Navbar dark color="primary">
<div className="container">
<NavbarBrand href="/">my-brand</NavbarBrand>
</div>
</Navbar>
</div>
);
}
}
export default App;
Visual Studio 2017在这里给我一个错误:
#include "../../std_lib_facilities.h"
#include <stdlib.h>
//Write a program that consists of a while loop (each time around the loop) reads in two ints and then prints them. Exit the program when a terminating | is entered.
int main()
{
char temp;
char* endptr = 0;
while (temp != '|')
{
double value;
vector<int> values;
for (string temp; values.size() < 2;)
{
cin >> temp;
{
if (temp == "|")
break;
else
value = strtod(temp, &endptr);
values.push_back(value);
}
}
cout << values[0] << "\n" << values[1] << "\n" << "\n";
values.clear();
}
}
带有参数else
value = strtod(temp, &endptr);
的建议“不存在从“ std :: string”到“ const char *”的合适的转换函数”,这正是我期望strtod要做的函数。
答案 0 :(得分:5)
在使用C ++时,请改用std::stod()
(C ++ 11)