CString Substring

Hi good afternoon everybody,
I have a CString containing a datetime eg 20111213164136
But I need to be able to extract certain numbers from within it eg the year(0 to 4) or month(5 to 6)
Is there any way I can go about this easily?
You mean something like this? You could add to it to solve your problem.

1
2
3
4
5
6
7
8
9
10
#include <iostream>

int main(void) {
    const char arr[4] = { '1', '2', '9', '6' };
    for(int i = 0; arr[i] != '\0'; ++i) {
        if(arr[i] >= '0' && arr[i] <= '4') 
            std::cout << arr[i] << ' ';
    }
    return 0;
}

Someone here could probably find a better solution, but this is what I came up with.
Last edited on
That never occurred to me but would work perfectly,

Thank you
Topic archived. No new replies allowed.