This is what my problem is asking "Write a program that takes in a year as input (as a command line argument) and returns the string "{year} was a leap year'' if true and "{year} was not a leap year'' if false."
I feel I need to make leapYear = to something belonging to argv[1] but I'm a bit confused on what.
I did "leapYear = atoi(argv[1]);" at first but i'm now thinking its wrong
WHAT AM I DOING RIGHT AND WHAT AM I DOING WRONG?? Please help!!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
usingnamespace std;
int main(int argc, char*argv[]) {
int leapYear;
if (leapYear % 400 == 0 || (leapYear % 4 == 0 && leapYear % 100 != 0 ))
cout << argv[1] << "was a leap year" <<endl ;
else cout << argv[1] << "was not a leap" <<endl;
return 0;
}
I reworded the question lol I did "leapYear = atoi(argv[1]);" based on help from a classmate when I asked a question previously but i'm thinking it was wrong in a way or I'm missing something along with it. I got the error code Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)
**also I changed the header and still received the same error message
thank you for your help, I realized I did the problem correct at the beginning after I resubmitted it to my instructor. Seems like I understand it overall I was just reallllly overthinking it and freaking myself out.