Hello,
I'm a student and i'm learing arduino. This is for a school project and i need to get the month out of DATE. I wanted to do it with a buf but doesn't output anything... What am i doing wrong or is there an easier way to get the month into a char?
For some context the ultimated goal is to get the month but in a number so DATE outputs:
Jun 4 2022 if i'm not mistaken. I would like to get the month number so Jun = sixth month so i would like to get 6. I wanted to put it in a buf and than use an array to get the correct number. I hope it is somewhat understandable. I would really appreciate some help! Thanks in advance.
This is what i have now:
char monthBuf[30];
String compileDate = __DATE__;
char firstCharMonth = compileDate[0];
char secondCharMonth = compileDate[1];
char thirdCharMonth = compileDate[2];
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
strcpy(monthBuf, firstCharMonth);
strcat(monthBuf, secondCharMonth);
strcat(monthBuf, thirdCharMonth);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(monthBuf);
}