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. Other Discussions
  3. Clever Code
  4. Semicolon after if-statement

Semicolon after if-statement

Scheduled Pinned Locked Moved Clever Code
help
2 Posts 2 Posters 2 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.
  • J Offline
    J Offline
    Jake86954
    wrote on last edited by
    #1

    Semicolon after if-statement : int a = 10; if(a == 2); // Bug ! There shouldn't be a semicolon here ! System.out.println("This line will now ALWAYS be executed !");

    J 1 Reply Last reply
    0
    • J Jake86954

      Semicolon after if-statement : int a = 10; if(a == 2); // Bug ! There shouldn't be a semicolon here ! System.out.println("This line will now ALWAYS be executed !");

      J Offline
      J Offline
      Jummna
      wrote on last edited by
      #2

      Again, as I just posted, as someone who uses the Digital Mars C++ compiler (formerly Symantec C++ and before that Zortech or the like) I never get this problem as the compiler always warns of the semi=colon. In the unlikely case where you do want a semicolon, to keep the compiler happy, you just need to insert some C comment: while (flag) /* Wait */; Paul

      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