_strdate and ints, help

This is a discussion on _strdate and ints, help within the C Programming forums, part of the General Programming Boards category; so i have Code: char dateStr [9]; char timeStr [9]; _strdate( dateStr); _strtime( timeStr ); I know i can transform ...

  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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21