Thread: _strdate and ints, help

  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    10

    _strdate and ints, help

    so i have

    Code:
     char dateStr [9];
              char timeStr [9];
              _strdate( dateStr);
                       _strtime( timeStr );



    I know i can transform strings into ingeters using atoi, but how do i get only the X's in XX/XX/XXXX, the question is, how do i break down the string?

  2. #2
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Use a combination of strchr() and strtol() in a loop. Strtol reads up until the first non valid character (i.e non numeric) and strchr() returns a pointer to the character you are looking for, in this case '/'. Atoi() is depricated, use strtol() instead.

  3. #3
    Registered User
    Join Date
    Jul 2010
    Posts
    10
    thanks!

Popular pages Recent additions subscribe to a feed