Directory Listing | |
---|---|
argtest.cpp
|
|
point3d.cpp
|
|
string_to_int.cpp
|
|
test.ppm
|
|
vec_ex.cpp
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
double string_to_double(string str) {
double value;
istringstream is;
is.clear();
is.str(str);
is >> value;
return value;
}
int main() {
string cheese = "123.456";
cout << (string_to_double(cheese) + 1) << endl; //Should print "124.456"
}