cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Grabbing the numbers from a string and s
Grabbing the numbers from a string and storing them
Oct 6, 2016 at 7:51am UTC
onlincutie
(5)
How would I go about grabbing numbers in a string and storing them into a variable?
Example: A user inputs longitude and latitude along with the locations name
20.8987/N 156.4305/W Kahului Airport
47.4647/N 8.5492/E Zurich Airport
How do I read each line, get the numbers(doubles) that I want, as well as the location name? And store each in their appropriate variable
Oct 6, 2016 at 11:14am UTC
Nico
(251)
How do I read each line:
user input:
http://www.cplusplus.com/reference/istream/istream/getline/
input file:
http://www.cplusplus.com/doc/tutorial/files/
get the numbers(doubles) that I want:
http://www.cplusplus.com/reference/cstring/strtok/
http://www.cplusplus.com/reference/string/string/substr/
http://www.cplusplus.com/reference/string/stof/
as well as the location name:
Should be trivial now.
The next likely obstacle:
http://www.cplusplus.com/doc/tutorial/control/
Topic archived. No new replies allowed.