Accept the string from the user.
Find the date from the given string with ddmmyyyy format and display the output as:"date found = "
Eg:input:Eg: abc0712201345bye
output:date found =07122013
how to do this?
Accept the string from the user.
Find the date from the given string with ddmmyyyy format and display the output as:"date found = "
Eg:input:Eg: abc0712201345bye
output:date found =07122013
how to do this?
have you learned pointers yet? You will need to use a pointer to find the first digit character in the string. Then use a loop to print the next 8 digits to the screen, one digit at a time.
If you sat down at the desk or table, and was given this string, could YOU find the date digits, inside the string?
How would you do it?
You'd probably start at one end of the string, and look through the string, for the first digit.
When you found the first digit, you'd start counting the next part of the string, and see if that first digit was followed by 7 more digits, to total 8 digits. If you have 8 digits total, then you have the date digits. If not, then you keep moving through the string.
You could use pointers for this, but you can do it without any pointers, very well. Use a while(), or a do while(), or a for() loop, and checking each char as you move through the string.
It's always good to start an unknown algorithm, with the computer mimicking how you would do it. Computers have mad skills we don't, so they can use more efficient techniques many times, but we humans are pretty efficient also most times, given the talents we have.
Try that.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.