c - week day finder strange behavior -


This is a week's finder program that I have put together. Everything works as much as what is needed, but for one thing I have some problems. It will only take the date format / dd / mm / yyyy.

What I can not understand: is a function that checks that entry date is valid that the entry date is in the month and month is worth

Program:

#include & lt; Stdio.h & gt; # Include & lt; Stdbool.h & gt; #include & lt; String.h & gt; # Include & lt; Stdlib.h & gt; # Size 15 Type TrueFile * String; String Weekday [7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; Int month-to-day [12] = {31,28,31,30,31,30,31,31,30,31,30,31}; // function prototype zero getInput (string sign, int * day, int * month, int * year); Bool dateChecking (int * days, int * month, int * year); Bull is Liepier (int year); Int getCenturyValue (Int. Years); Int ware vera (int year); Int getMonthValue (int month, int year); // Read the date to analyze zero getInput (string prompt, int * day, int * month, int * year) {int success; Four buffer [SIZE]; Do {printf ("% s", prompt); Fgets (buffer, size (buffer), staden); Success = sscanf (buffer, "% i /% i /% i", day, month, year); If ((success: lieutenant; 3) ||! (Ranking (day, month, year)) printf ("You have an invalid entry, please try again. \ N");} while ((success and lieutenant; 3) ||! (Checking (day, month, year))} // Check that there are acceptable categories in the days and months.Bool dateChecking (int * day, int * month, int * year) {if (leap Year (* year)) month_desk [1] = 29; if (* month and lieutenant; 13) returns (* day & lt month; [month-1]); second false return;} // returns true if The year is the year of a leap year, Bull is Leipair (int word) {returns (years% 400 == 0)} ((year% 4 == 0) & amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp;% Year = 100! = 0) );} Remove the first two digits of the year, and according to the assignment space // process it. Int getCenturyValue (int year) {int value = year / 100; return 2 * (3 - (value% 4)); } Remove the last two digits of the year, and according to the assignment space, // process it.Intere ware (int word) {int value = year - ((year / 100) * 100); return value + (value / 4);} // switch statement Modes Each month its value int getMonthValue (Int month, Int year) {int value = 0; Switch (Month) {Case 1: Value = HELP year (year)? 0: 6; break; Case 2: Price = HypePier (years)? 3: 2; break; Case 3: Price = 3; break; Case 4: Value = 6; break; Case 5: Price = 1; break; Case 6: Value = 4; break; Case 7: Value = 6; break; Case 8: Price = 2; break; Case 9: Value = 5; break; Case 10: Value = 0; break; Case 11: Value = 3; break; Case 12: Value = 5; break; } return value; } Int main () {int day, month, year, sum; GetInput ("Enter a date in the following formats: dd / mm / yyyy:", & amp; nbsp; days, & amp; months, & amp; nbsp; years); Sum = day + getMonthValue (months, years) + Receive YearValue (year) + Receive Contribution Value (year); Printf ("Date specified:% s", weekdays [amount% 7]); Printf ("\ n \ n \ n"); Return 0; }

You must change % i to sscanf with% D . Use the predefined numbers as Octak as 0 using % i .


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -