my compilation error

Discussion in 'C' started by vidhi gupta, Nov 19, 2010.

  1. vidhi gupta

    vidhi gupta New Member

    Joined:
    Nov 19, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    error 1:
    Code:
    for(int i=0;i<20;i++)
    [problem: for statement missing]
    error 2:
    Code:
    void pass()
    {
    char passw[20];
    for(;;)
    }
    
    [problem:functions containing for are not explained inline]
     
  2. ihatec

    ihatec New Member

    Joined:
    Sep 1, 2010
    Messages:
    20
    Likes Received:
    3
    Trophy Points:
    0
    In first case the second statement is missing. You tried i<20; but you used entitity for less that.

    In second case your function do nothing. It allocates memory for 20 chars, and then you tried some infinite loop but without any statement after it. When you use loops they must contain a statement that will execute for some number of times.
    Code:
    int i=0;
    while(i<4)
    {
          printf("%i", i);
          i++;
    }
    int i=0;
    do
    {
          printf("%i", i);
          i++;
    }while(i>8);
    int i;
    for(i=0;i<10;++i)
    {
         printf("%i",i);
    }
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice