Passing structure out of the functions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gnanapoongothai
    New Member
    • Jun 2007
    • 62

    Passing structure out of the functions

    I have a query like i have a structure being called in the function and the values get calculated in the function. and once i am out of the function all the values in th structure are now showing value zero, Now i want the values of the structure in the calling function also.
    What can be done.



    i have a function called f1() in which i have defined the struct timeformat as global . And i am calling a function f2(timeformat time). again in the f2 also i have declared the structure . what has to be done to get the values of the struct in f1() which is modified by f2().

    hope you follow the question.

    thanks .
  • ashitpro
    Recognized Expert Contributor
    • Aug 2007
    • 542

    #2
    Originally posted by gnanapoongothai
    I have a query like i have a structure being called in the function and the values get calculated in the function. and once i am out of the function all the values in th structure are now showing value zero, Now i want the values of the structure in the calling function also.
    What can be done.



    i have a function called f1() in which i have defined the struct timeformat as global . And i am calling a function f2(timeformat time). again in the f2 also i have declared the structure . what has to be done to get the values of the struct in f1() which is modified by f2().

    hope you follow the question.

    thanks .

    Have you heard about Pass By Reference..
    If not search on google.
    I think this is the solution for you..

    Comment

    • hdanw
      New Member
      • Feb 2008
      • 61

      #3
      Show us the code.

      You have declared NOTHING global within a function declaration.

      Code:
      int   this_is_a_global_int;
       
      void functionone()
      {
      	 int this_is_a_local_int;
      	// this function can see both ints
      }
       
      void functiontwo()
      {
      	// this function can only see one int
         //   this_is_a_global_int;
      }

      Comment

      Working...