Thread: Question about a programming technique to find if certain digits are inside a int

1. Question about a programming technique to find if certain digits are inside a int

Hey all, for example let's say I have

Code:
```sscanf(line, "%s" %d"", string, &date_id);
```

I am still learning, not that familiar with all the functions but I am coding more, what would be the best function to use (i am using the tutorialspoint web site for tutorials) to for example see if the first digits of an 11 digit int would be "01_", "02_", "03_", meaning 01 for January, 02 for February, 03 for March, and remaining 8 digits are MMDDYYYY. I have

Code:
`#define DIGITS 11`
this set too. I was wondering, would the modulus operator be a good choice to use in deciding what the first two digits are being inputted. I would like to use a loop that would just break out of the first digits 01_ => 12_ aren't entered. Thanks.

2. I did a quick search on fscanf() since these 01_, 02_ & 03_ etc are in a txt file I was thinking I can just use "01" for month, without the complicated underscore then the remaining 8 digits (for example 01_01142020 for meeting 1, jan 14 2020)

Comment's appreciated.

3. Why are the data strings, "01_01142020"? Isn't that "MM_MMDDYYYY"? Seems like redundant redundancy!

Why do you need the leading "MM_"? Why not just use the final 8 digits, "MMDDYYYY"? It is very easy to extract the Month number form the string.

Code:
```#define DIGITS 11
// should be
#define DIGITS 12 // or more!  You need to allow room for the trailing Nul byte!```
Can you give us the link for this problem on the Tutorialpoint site?

4. rstanley, I've moved on.

I'm using int's for MEETING_NUMBER, month, day & year. Yes the underscore was redundant.