give one variable from one module to another

This is a discussion on give one variable from one module to another within the C Programming forums, part of the General Programming Boards category; Hello I have a quick question. I have a module and in this module i have a linked list. I ...

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    115

    give one variable from one module to another

    Hello

    I have a quick question. I have a module and in this module i have a linked list.
    I want to give the linked list head to another module. So just that address.
    Is this possible without writing a function?

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    To me, "modules" are very high-level software engineering terms, and are incredibly ambiguous in any other context (such as what you have given).

    If you want to share anything, without exposing it via a function, then that variable simply must have global visibility.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,208
    Can you explain how you can produce a module in C that does something and doesn't involve writing a function?
    Right 98% of the time, and don't care about the other 3%.

  4. #4
    Registered User
    Join Date
    Feb 2010
    Posts
    115
    im sorry i forgot to mention we cant use global variables

  5. #5
    Registered User
    Join Date
    Feb 2010
    Posts
    115
    Quote Originally Posted by grumpy View Post
    Can you explain how you can produce a module in C that does something and doesn't involve writing a function?
    Well for my schoolproject I need to write a little game about meerkats and his enemies

    I have modules surface, underground and simulation

    I use in simulation something from surface and I need only the linkedlist header from underground

  6. #6
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    I don't think it's possible. If you can't have a global variable, or a "getter" function for a private/local variable, then, again I don't see how it would be accomplished.

    An analogous question might be: how do you enter a locked house without access to the key and without asking the doorman? If your answer is to "break the window" or something else illegal, then maybe the programming-equivalent solution is illegal too.

  7. #7
    Registered User
    Join Date
    Feb 2010
    Posts
    115
    Ok thank you for the information

  8. #8
    Registered User
    Join Date
    Jun 2005
    Posts
    6,208
    Quote Originally Posted by thescratchy View Post
    Well for my schoolproject I need to write a little game about meerkats and his enemies

    I have modules surface, underground and simulation

    I use in simulation something from surface and I need only the linkedlist header from underground
    OK .... will you explain how that provides an answer to my question?
    Right 98% of the time, and don't care about the other 3%.

  9. #9
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    Quote Originally Posted by grumpy View Post
    Can you explain how you can produce a module in C that does something and doesn't involve writing a function?
    My understanding is that he/she isn't allowed to write a "getter" function for the variable. Not that he/she can't use other functions in the "module".

  10. #10
    Registered User
    Join Date
    Feb 2010
    Posts
    115
    I cant use global variable but they didn't say i cant use "getter" functions but c isnt objective so what do you mean with a getter function?

  11. #11
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    OK, that's the literal interpretation of what I said. But, of course, this isn't OOP so there's no "getter" function to get a "private member" of a "class".

    In general (for non-OOP) languages, how do you pass information? With global variables and functions. But you said you can't do either of those, so I don't see a way to do it.

    Hopefully the question wasn't ambiguous and worded improperly, of course you can pass information using things like pipes, files, or other shared memory approaches. However, the only way to do this is to write the code for it "in a function"--again, out of the question according to what you've told us. My guess is that whoever told you the requirements is ambiguous, or you misunderstood what they said. I'd try to clarify with them.

  12. #12
    Registered User
    Join Date
    Feb 2010
    Posts
    115
    No, ok that was what i thought. I am going to ask monday some more information at one of the assistants. Thank you for your time

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How accurate is the following...
    By emeyer in forum C Programming
    Replies: 22
    Last Post: 12-07-2005, 11:07 AM
  2. Replies: 2
    Last Post: 04-12-2004, 01:37 AM
  3. Beginner question
    By Tride in forum C Programming
    Replies: 30
    Last Post: 05-24-2003, 08:36 AM
  4. Need help
    By awkeller in forum C Programming
    Replies: 2
    Last Post: 12-09-2001, 02:02 PM
  5. Variable Allocation in a simple operating system
    By awkeller in forum C Programming
    Replies: 1
    Last Post: 12-08-2001, 01:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21