1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

help with scanf();

Discussion in 'C' started by lionaneesh, Mar 24, 2010.

  1. lionaneesh

    lionaneesh New Member

    Joined:
    Mar 21, 2010
    Messages:
    848
    Likes Received:
    224
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    India
    Code:
    scanf("%[^\n]",line);
    tell me the logic of this scanf statement and why " [^\n] " is used instead of %s ...
    and how this statement works...

    i know that this statement inputs lines till enter is pressed..

    but what is the format of the scanf statements please tell...
     
  2. karthigayan

    karthigayan New Member

    Joined:
    Feb 19, 2010
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    0
    It is equal to gets . By default scanf will read the input until it receives a word separator ( space,tab,etc ).

    We can change that to some character . Here you changed to read until the new line ( Read the characters other than '\n' .If '\n' it will get end ) .
     

Share This Page