I can't figure out why my program is not running
-
/* William Strickland Project 3 Is Leap Year Portion */ #include #include #include "..\..\stdbool.h" bool isLeapYear(int *year); int main(int argc, char *argv[]) { int year = atoi(argv[4]); printf("Name: William Strickland \n"); printf("Is Leap Year \n"); if (isLeapYear(&year)) { printf("%d is a leap year", year); } else { printf("%d is not a leap year", year); } return 0; } bool isLeapYear(int *year) { if (*year % 4 == 0 && *year % 100 != 0) { return 1; } else if (*year % 100 == 0 && *year % 400 == 0) { return 1; } else { return 0; } }
-
/* William Strickland Project 3 Is Leap Year Portion */ #include #include #include "..\..\stdbool.h" bool isLeapYear(int *year); int main(int argc, char *argv[]) { int year = atoi(argv[4]); printf("Name: William Strickland \n"); printf("Is Leap Year \n"); if (isLeapYear(&year)) { printf("%d is a leap year", year); } else { printf("%d is not a leap year", year); } return 0; } bool isLeapYear(int *year) { if (*year % 4 == 0 && *year % 100 != 0) { return 1; } else if (*year % 100 == 0 && *year % 400 == 0) { return 1; } else { return 0; } }
0. Please edit your question and wrap your code in the appropriate tags. 1. "Not running" isn't very descriptive. Are you failing to hit the enter key after typing the name of the program ina console window, are you only building the program but not running it from an IDE, or perhaps, you're running the program and it produces unexpected output.. 2. The program runs just fine. 3. This is the output I get when running from the console. (I assume you understand what argv[4] refers to. Hint: it's not a 4 character long input. argv[0] would hold "001-deleteMePlease" "001-deleteMePlease.exe")
D:\code\001-deleteMePlease\bin\Release>001-deleteMePlease.exe 1 2 3 2000
Name: William Strickland
Is Leap Year
2000 is a leap year"When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'happy'. They told me I didn't understand the assignment, and I told them they didn't understand life." - John Lennon