Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Global Scope in C

Global Scope in C

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arsalan Malik
    wrote on last edited by
    #1

    I have a situation similar to following: int b; int afunction() { int b = 0; ... } I need to access global b in afunction?? C does not have :: operator. I cannot change the identifier of both local and global variable b. Is there a way around??:confused: ARSALAN MALIK

    2 D C H 4 Replies Last reply
    0
    • A Arsalan Malik

      I have a situation similar to following: int b; int afunction() { int b = 0; ... } I need to access global b in afunction?? C does not have :: operator. I cannot change the identifier of both local and global variable b. Is there a way around??:confused: ARSALAN MALIK

      2 Offline
      2 Offline
      224917
      wrote on last edited by
      #2

      Arsalan Malik wrote: I need to access global b in afunction?? No, there is no such operator in C language. Arsalan Malik wrote: Is there a way around?? May be you can write a getter function for the global b. ;)


      suhredayan
      There is no spoon.

      1 Reply Last reply
      0
      • A Arsalan Malik

        I have a situation similar to following: int b; int afunction() { int b = 0; ... } I need to access global b in afunction?? C does not have :: operator. I cannot change the identifier of both local and global variable b. Is there a way around??:confused: ARSALAN MALIK

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Arsalan Malik wrote: Is there a way around?? Yes, don't use b in both spots.


        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

        1 Reply Last reply
        0
        • A Arsalan Malik

          I have a situation similar to following: int b; int afunction() { int b = 0; ... } I need to access global b in afunction?? C does not have :: operator. I cannot change the identifier of both local and global variable b. Is there a way around??:confused: ARSALAN MALIK

          C Offline
          C Offline
          CodeBeetle
          wrote on last edited by
          #4

          Try this:- int b; int afunction() { extern int b = 0; ... }


          CodeBeetle.Com


          1 Reply Last reply
          0
          • A Arsalan Malik

            I have a situation similar to following: int b; int afunction() { int b = 0; ... } I need to access global b in afunction?? C does not have :: operator. I cannot change the identifier of both local and global variable b. Is there a way around??:confused: ARSALAN MALIK

            H Offline
            H Offline
            haritadala
            wrote on last edited by
            #5

            Try this int b; int afunction() { int *ptr= &b; int b = 0; ..... }

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups