regarding storage classes in C

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • patelss23
    New Member
    • Jul 2007
    • 16

    regarding storage classes in C

    Hello All,
    how are you?

    Can you please make me aware of storage specifiers like volatile, extern, and register ? I know the in what situations they can be used. But till this date I haven't seen any practical example using volatile or register.

    can you please let me know ?

    Thank you in advance,
    Sanket
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    As this smells suspiciously of homework, I'm going to ask, what do you think are practical examples?

    Comment

    • patelss23
      New Member
      • Jul 2007
      • 16

      #3
      Originally posted by sicarie
      As this smells suspiciously of homework, I'm going to ask, what do you think are practical examples?
      Hello sicarie,

      This is not a homework question. Actually I am done with my graduation already. And I have also got some field experience too. I have started revising C so I can look at things from different perspective.

      I read that by keeping your variable volatile any other process can change it. But I haven't come across such situation. So I was wondering where and how such storage specifiers are used.

      Thank you

      Comment

      • sicarie
        Recognized Expert Specialist
        • Nov 2006
        • 4677

        #4
        Cool.

        So can you think of any cases where that might be practical?

        Comment

        • patelss23
          New Member
          • Jul 2007
          • 16

          #5
          Originally posted by sicarie
          Cool.

          So can you think of any cases where that might be practical?
          Yes .. There are some .....
          For example, there are two programs which are using the same resource, it could be a file, some shared area of memory or anything. But What I am not getting is ..... why do we need to keep it volatile ? I havent seen this keyword in any code I have come across. Does this have some relation to access protection mechanism of Operating System ? I am not getting any concrete solution to this.

          Thank you,
          Sanket

          Comment

          Working...