EmbLogic's Blog

why not Address operator & used with the string variables in scanf function and used for other types??..

3 Responses to why not Address operator & used with the string variables in scanf function and used for other types??..

  1. kamran says:

    Nice question , but very less guys think to that extend.
    So to explain if we take an an string of char, and save some information in it, we don;t use & operator because string save only the information of the first address only and after that it is allocated in continuous manner . Hence if we can get the first address rest can be find by incrementing the address as per the variable declaration.

    Secondly, the & operator is used to get the address of the variable and since string is collection of continuous memory location, we dont need the & operator.

    Hope that help.

  2. zaffer says:

    the & operator points towards the address. when we declare the string by default the address of the first location is pointed unless we specify the position of char in a string.

  3. yeah, mr jaffar thats it ,but i want more comprehension.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>