473,406 Members | 2,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 .
Feb 5 '08 #1
2 1074
ashitpro
542 Expert 512MB
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..
Feb 5 '08 #2
hdanw
61
Show us the code.

You have declared NOTHING global within a function declaration.

Expand|Select|Wrap|Line Numbers
  1. int   this_is_a_global_int;
  2.  
  3. void functionone()
  4. {
  5.      int this_is_a_local_int;
  6.     // this function can see both ints
  7. }
  8.  
  9. void functiontwo()
  10. {
  11.     // this function can only see one int
  12.    //   this_is_a_global_int;
  13. }
  14.  
Feb 5 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Steven Taylor | last post by:
Hope someone can assist. I'm trying to answer a book question. I'm going around in circles in relation to 'pointer-to-char'. Object : A short program is to be created, which involves a...
0
by: nygiantswin2005 | last post by:
I am tring to write simple console application in C# to test the APIs functions made available by the dymo sdk. The dymo sdk provides a dll library that can be used to call functions that will...
8
by: Bryan G | last post by:
Hi, I'm working on a VB project which involves using C library functions which take struct pointers as args, and I keep running into this error when trying to pass either an IntPtr or a Structure...
2
by: Steve Turner | last post by:
I have read several interesting posts on passing structures to C dlls, but none seem to cover the following case. The structure (as seen in C) is as follows: typedef struct tag_scanparm { short...
11
by: Macca | last post by:
Hi, I'm writing an application that will pass a large amount of data between classes/functions. In C++ it was more efficient to send a pointer to the object, e.g structure rather than passing...
4
by: sofeng | last post by:
The following link shows a chart I created about passing structures among functions. Would you review it and tell me if it requires any corrections? ...
7
by: pereges | last post by:
which one do you think is better ? I need to make my program efficient and in some places I have passed the copy of a variable which makes life some what easy while writing huge expressions but...
6
by: Andy Baker | last post by:
I am attempting to write a .NET wrapper for a C++ DLL file, but am having problems with passing strings as parameters. How should I be writing my C# function call when the C header file is...
13
by: Andy Baker | last post by:
I am attempting to write a .NET wrapper in C# for an SDK that has been supplied as a .LIB file and a .h header file. I have got most of the functions to work but am really struggling with the...
0
by: =?Utf-8?B?Uk9MU1Q1?= | last post by:
I have a native win32 C++ DLL that has exported functions (I can't modify the win32 DLL). One of these exported functions needs a pointer to a structure. The structure contains virtual functions. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.