Thread: Can anyone explain to me...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    11

    Can anyone explain to me...

    Why this for loop only goes once?

    Code:
    int y=0, P = 4;
        for (y = 0; y<P; y++);
        {
            printf("this does not bode well...%d\n", y);
        }
    Right off the bat, y is set to four for some reason and I can't seem to change it...

    EDIT: Oh, goddammit, who put that semi-colon there. If someone could delete this post, that'd be great, thanks.
    Last edited by Flamefury; 11-09-2009 at 10:58 PM.

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,337
    Code:
     for (y = 0; y<P; y++);
    Mainframe assembler programmer by trade. C coder when I can.

  3. #3
    Registered User rpbear's Avatar
    Join Date
    Nov 2009
    Posts
    18
    look at the end of the for,you add one ;
    that's a mistake caused by careless~~

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you explain these bitwise operations?
    By 6tr6tr in forum C++ Programming
    Replies: 6
    Last Post: 10-29-2008, 01:19 PM
  2. Replies: 6
    Last Post: 08-23-2008, 01:16 PM
  3. One Easy" C " Question. Please Solve and Explain.
    By RahulDhanpat in forum C Programming
    Replies: 18
    Last Post: 03-24-2008, 01:39 PM
  4. Please Explain me few terms that i have listed in here.
    By chottachatri in forum C++ Programming
    Replies: 3
    Last Post: 02-26-2008, 08:20 AM
  5. Can someone explain "extern" to me?
    By valar_king in forum C++ Programming
    Replies: 3
    Last Post: 09-16-2001, 12:22 AM