I'm using visual studio for the program. When i prompt the user for date like is this format -dd/mm/yyyy . For the program how do i use the data for just the year only not the whole input?
pokemon123 0 Newbie Poster
Recommended Answers
Jump to Post>>how do i use the data for just the year only not the whole input?
convert the last four characters of the string to an integer. There are several ways to do that but the simplest is to call atol()
std::string date = "07/05/2007"; int year …
Jump to PostThere are many ways to do this. The first that springs to mind is to use the "/" as a delimiter to split the string into parts (tokens).
All you really need to do then is get the last part and convert it to an integer, which should really …
All 6 Replies
Bench 212 Posting Pro
pokemon123 0 Newbie Poster
Bench 212 Posting Pro
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
pokemon123 0 Newbie Poster

iamthwee
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.