by karthick hari on February 8th, 2006

karthick hari

Question

Help answer this question below.

What does a while(1) mean in C?

  • Like
  • Report

Answers. 5 helpful answers below.

  • by Jon Perryman on February 11th, 2006

    Jon Perryman

    WHILE(1) causes a permanent loop (a loop that executes for ever). A break statement will cause the loop to end. To see some sample code using this method, look at http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html

    • Like
    • Report

    No comments. Post one | Permalink

  • by Michael_E4534 on September 28th, 2010

    Michael_E4534

    Check this out for an excellent answer to your question:


    http://stackoverflow.com/questions/885908/while-1-vs-for-is-there-a-speed-difference

    • Like
    • Report

    No comments. Post one | Permalink

  • by dheeraj on May 26th, 2007

    dheeraj

    while(1) mean it is an infinite loop.we can stop it only through it a condition that use break stament.

    • Like
    • Report

    No comments. Post one | Permalink

  • by tigueron on November 27th, 2006

    tigueron

    that's because in C, 1 means true, 0 means false, so it would be while(true)

    other ways to do it
    while(1=1)
    while(2>1)
    while(3<>8)
    while(this_code_is_executing)
    (since it doesn't matter if it is not)

    • Like
    • Report

    1 comment | Post one | Permalink

  • by DeusDark on April 1st, 2007

    DeusDark

    while(1) == While(!0) == While(42)
    == While(something), where ! is not. Logic is as follows: If(1 is not 0), repeat.

    No comments. Post one | Permalink

Want to attach an image to your answer? Click here.

Did this answer your question? If not, then ask a new question or create a poll.

More Questions. Additional questions in this category.

You're reading What does a while(1) mean in C?

Follow us on Facebook!

Related Ads

ANSWERBAG BUZZ

While 1
While 1
While 1 in c
C while 1
C while true