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 :
C Program To Swap Two Numbers Without Using Third Variable
Learn More :
String
- Write a c program to check given string is palindrome number or not.
- C Program to Convert Text String to Binary
- C Program String - Alphabet Count Example
- C Program String Example
- C Program String Count Example
- C Program String Example
- C Program to Print a String Without Use Semicolon.
- C Program To Find Length Of A String Including Blank Spaces, Tabs, And Other Special Characters
- C Program To Find Length Of String And Concatenate Two Strings
- C Program To Find The Length, Reverse Of A String And To Check It Is Palindrome or Not
- C Program To Print String In Formatted Output Form
- C Program To Reverse The String Using Pointer
- C Program Concatenating Two Strings Into A Third System
- BUILDS A STRING FROM THE LSB BITS OF EACH PIXEL
- C Program Finds Sub-String Search in String
- C Program to concatenate two strings without using string functions
- C Program to Count Vowels, Consonants and Spaces in a string
- C Program to convert a string to upper case
- C Program Performs a search and replace for a specified target and replacement string
- C Program Anagrams
- C Program to find string length without library function
- C Program to Check Given String is Palindrome or Not
- C Program to Converts a Number to a String.
- Design a C function that shortens a string to 8 characters