What is a null statement in C language?

Discussion in 'Programming' started by fun2sh, Jul 12, 2007.

Thread Status:
Not open for further replies.
  1. fun2sh

    fun2sh Pawned!... Beyond GODLIKE

    Joined:
    May 2, 2006
    Messages:
    1,062
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    World Of Warcraft -DOTA
    hi guys today my first sem computer exams got over.
    one question in paper was WHAT IS A NULL STATEMENT? how it is useful? can some1 tel me the ans.
    i wrote a statement followed by double semi colon where second semi colon acts like a null statement. m i right?

    koi to batao bhai log
     
    Last edited: Jul 12, 2007
  2. slugger

    slugger Banned

    Joined:
    May 9, 2004
    Messages:
    2,430
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Baudland
    you cud check out the meaning of Null Statement from here
     
    Last edited: Jul 12, 2007
  3. Zeeshan Quireshi

    Zeeshan Quireshi C# Be Sharp !

    Joined:
    Jun 9, 2006
    Messages:
    1,805
    Likes Received:
    5
    Trophy Points:
    0
    Location:
    Toronto
    simply saying a nul statement is a "blank" statement , it absolutely does not do anything , it is terminated like any normal statement by a semicolon ';' .

    e.g.
    Code:
    int x=5; // this stament is not null
    ; // this one's null
    x=9; //another statement
    
     
  4. Manshahia

    Manshahia Resident Fanatic

    Joined:
    Jul 23, 2006
    Messages:
    910
    Likes Received:
    3
    Trophy Points:
    0
    Location:
    /Milky way/earth/india/
    wat is its use then??
     
  5. abhishek_del

    abhishek_del New Member

    Joined:
    Apr 17, 2005
    Messages:
    133
    Likes Received:
    0
    Trophy Points:
    0
    it is like

    int *p=NULL;
    here p is a pointer and above statement, initializes a pointer p with null value....this is what is null, nothing else....
    It is useful in pointers, to check if they are not inititalized to wrong places or not pointing to places where windows is using the memory..
     
  6. casanova

    casanova The Frozen Nova

    Joined:
    Sep 25, 2004
    Messages:
    1,641
    Likes Received:
    2
    Trophy Points:
    0
    Location:
    Trespasser in Virtual Land
    It says don't do anything. Used mostly in conditions and loops.
     
  7. Zeeshan Quireshi

    Zeeshan Quireshi C# Be Sharp !

    Joined:
    Jun 9, 2006
    Messages:
    1,805
    Likes Received:
    5
    Trophy Points:
    0
    Location:
    Toronto
    it's used in loops n stuff when you don't want to do anything and the syntax demands that you provide atleast one statement for execution :)
     
  8. Rollercoaster

    Rollercoaster -The BlacKCoaT Operative-

    Joined:
    Mar 10, 2005
    Messages:
    1,206
    Likes Received:
    17
    Trophy Points:
    0
    Location:
    Dehradun, India
    one possible use in loops

    for ( ; ; ) {
    ....
    ....
    ....
    }
     
  9. OP
    fun2sh

    fun2sh Pawned!... Beyond GODLIKE

    Joined:
    May 2, 2006
    Messages:
    1,062
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    World Of Warcraft -DOTA
    hey its a blank followed by a semicollon. just like wat i said. i checked on net. i got the result. it seems u guys hav to study C a bit more:mrgreen:
     
  10. ahref

    ahref eWebGuru

    Joined:
    Mar 11, 2006
    Messages:
    427
    Likes Received:
    7
    Trophy Points:
    0
    Location:
    Dehradun
    I think many of the above post also says same thing.
     
  11. tanvi chaturvedi

    tanvi chaturvedi New Member

    Joined:
    Apr 24, 2007
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    0
    hy was goin thru it... n ques struck in mind..
    Q: wats d ASCII value of NULL..
    Q: in characters hw to represent NULL.. ?
     
  12. ahref

    ahref eWebGuru

    Joined:
    Mar 11, 2006
    Messages:
    427
    Likes Received:
    7
    Trophy Points:
    0
    Location:
    Dehradun
    ASCII value =0
    represented as '\0'
     
Thread Status:
Not open for further replies.

Share This Page