Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. I can't figure out why my program is not running

I can't figure out why my program is not running

Scheduled Pinned Locked Moved C / C++ / MFC
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 11160377
    wrote on last edited by
    #1

    /* 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; } }

    enhzflepE 1 Reply Last reply
    0
    • U User 11160377

      /* 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; } }

      enhzflepE Offline
      enhzflepE Offline
      enhzflep
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups