How to write a C Program Date from string DDDD-DD-DD in C Programming Language ?
Solution:
/*C Program Date from string DDDD-DD-DD*/
// getting date from string
// resetting l
l = 0;
// if my calculations are correct, when this baby gets two dashes, you´re gonna see some serious shit
for (l = 0; l <= len; l++){
if (slovo[l] == '-'){
if (slovo[(l+3)] == '-' && slovo[(l+5)] != '\0' && slovo[(l+6)] == '\0'){
isDate = 1;
getYear = (l-1);
getMonth = (l+3);
getDay = (l+6);
m = 0;
for (m = 0; m <= getYear; ++m){
year = atoi (&slovo[m]);
break;
};
m = 0;
for (m = (getYear+2); m < getMonth; ++m){
month = atoi (&slovo[m]);
break;
};
m = 0;
for (m = (getMonth+1); m < getDay; ++m){
day = atoi (&slovo[m]);
break;
};
break;
} else {
isDate = 0;
break;
}
};
};
You may also learn these C Program/Code :