how does std::stod work

Hi,

I am trying to convert multiple lines of strings to double with std::stod

I used the code found on the website:
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <sstream>
#include <string>
#include <fstream>
int main()
{
std::string two_doubles ="      22145.365        -3564789";
std::string::size_type K;
double first = std::stod (two_doubles, &K);
double second = std::stod (two_doubles.substr(K));
}


the string starts with white spaces. I get this error message when compiling:

warning unused variable 'first'
warning unused variable 'second'


How do you convert the two numbers in the string two_doubles to doubles?

Thanks
Z

They are not errors. It's just warning messages pointing out that the variables first and second are unnecessary because their values are never used in the program.
thank you! I figured out that something totally different is wrong with the code than std::stod! I am sorry for this question!
Topic archived. No new replies allowed.