How to access value of structure variable in different files using extern

i have a situation where i need to use variable of structure in different files. Where we will assign function returned value and use that assigned value as a arguments in some other functions of different files. please guide me with example how to go about on this situation.

Replies

  • Nayan Goenka
    Nayan Goenka
    use interface
  • Pushpendra2911
    Pushpendra2911
    Nayan Goenka
    use interface
    hello nayan please elaborate the interface . I am totally blank what you are talking about. What kind of interface we are talking here.
  • Nayan Goenka
    Nayan Goenka
    There is a concept in Java about interfaces. Where you can mass declare the functions in one object and use them in others. For detailed information Google it.
  • Pushpendra2911
    Pushpendra2911
    Nayan Goenka
    There is a concept in Java about interfaces. Where you can mass declare the functions in one object and use them in others. For detailed information Google it.
    dude i am a clean C programmer have no idea about java. Do you have any idea in C.
  • rahul69
    rahul69
    Pushpendra2911
    i have a situation where i need to use variable of structure in different files. Where we will assign function returned value and use that assigned value as a arguments in some other functions of different files. please guide me with example how to go about on this situation.
    For that, one easy way would be to include the files u need to use it in other files😀. For example u want to use the values from file a.c inside file b.c, so inside b.c just write:
    #include"a.c"
    Although this is not an efficient method, but it will work😁 .
    Good Luck , any doubts are welcomed👍 .
  • Pushpendra2911
    Pushpendra2911
    thanks rahul for your reply.
    but in my project i have whole library and i want to use value of one particular variable in several different file. your solution will be bit complicated.
  • Vishal Sharma
    Vishal Sharma
    Pushpendra2911
    thanks rahul for your reply.
    but in my project i have whole library and i want to use value of one particular variable in several different file. your solution will be bit complicated.

    Create project. In dev or visual IDE you have an option of creating Projects.
    Include all your supporting programs in this project and in your main program, include the other files.
    ex:
    your project has main.cpp and sol.cpp where main.cpp is your main file.. then in main.cpp add a line
    #include "sol.cpp"

    As far as I know, this concept works on object oriented programming languages like C++ n java etc.
    C is structural so not sure whether this will work
  • Pushpendra2911
    Pushpendra2911
    Vishal0203
    Create project. In dev or visual IDE you have an option of creating Projects.
    Include all your supporting programs in this project and in your main program, include the other files.
    ex:
    your project has main.cpp and sol.cpp where main.cpp is your main file.. then in main.cpp add a line
    #include "sol.cpp"

    As far as I know, this concept works on object oriented programming languages like C++ n java etc.
    C is structural so not sure whether this will work
    well thanx for your reply vishal
    i have theory knowledge on oops but never worked on any project.
    currently i am using linux opensuse and my IDE is netbeans 7 in which i am using C project included all library and files.
    good news is i have found the solution and now my code is running in live server.
    solution is extern keyword.
  • Vishal Sharma
    Vishal Sharma
    i'd like to see a example code!
  • Pushpendra2911
    Pushpendra2911
    Vishal0203
    i'd like to see a example code!
    my code is little complicated in order to share.
    so go through the below procedure and reply me if you succeed.
    suppose we have three .c files say 10th.c, 12th.c and main.c
    now do some marks calculation for 10th and 12th subjects using structure and functions in two different .c file i.e 10th.c and 12th.c
    now in main.h declare
    extern int passing_mark;
    in main.c define it as
    int passing_mark = 35;
    now in include main.h in all .c files.
    and just declare int passing_mark in 10th.c and 12th.c
    our work is done.
    now we can use the value of passing_mark in all .c files where main.h is included.
    even modification in our variable will be updated and can be used according to requirements.
    update me with any issue.
  • aman123
    aman123
    Pushpendra2911
    my code is little complicated in order to share.
    so go through the below procedure and reply me if you succeed.
    suppose we have three .c files say 10th.c, 12th.c and main.c
    now do some marks calculation for 10th and 12th subjects using structure and functions in two different .c file i.e 10th.c and 12th.c
    now in main.h declare
    extern int passing_mark;
    in main.c define it as
    int passing_mark = 35;
    now in include main.h in all .c files.
    and just declare int passing_mark in 10th.c and 12th.c
    our work is done.
    now we can use the value of passing_mark in all .c files where main.h is included.
    even modification in our variable will be updated and can be used according to requirements.
    update me with any issue.
    hello pushpendra...mself aman...need to talk to you...regardng cdac ccat....can i get ur contact no. or email id????? mine is
  • Pushpendra2911
    Pushpendra2911
    aman123
    hello pushpendra...mself aman...need to talk to you...regardng cdac ccat....can i get ur contact no. or email id????? mine is #-Link-Snipped-#
    yes buddy what ever you want to discuss. discuss it here i might not able to response you back from my gmail because of firewall in our office and i cant communicate with you through my official email id. what ever you have in your mind shoot it here i will reply as soon as possible.
  • aman123
    aman123
    Pushpendra2911
    yes buddy what ever you want to discuss. discuss it here i might not able to response you back from my gmail because of firewall in our office and i cant communicate with you through my official email id. what ever you have in your mind shoot it here i will reply as soon as possible.
    heyy,,,,, thnx buddy for ur response... i am appearing for c-cat 2013 aug...want to knw abt test... i knw d subjs... but something abt tpcs in sec-b and sec-a...meaning level of test and mostly which topics come under...sec a( ques type f verbal, quant,,reasonig) n sec b tooo.... mean there is no previous yr ques papaer on ne.....as i have to anyhow get into the course in good institute....pls help me...
  • aman123
    aman123
    Pushpendra2911
    yes buddy what ever you want to discuss. discuss it here i might not able to response you back from my gmail because of firewall in our office and i cant communicate with you through my official email id. what ever you have in your mind shoot it here i will reply as soon as possible.
    heyy, as i have left with only 15 days so can u help me abt tpcs which should i concntrate more f sec a n b
  • Pushpendra2911
    Pushpendra2911
    aman123
    heyy, as i have left with only 15 days so can u help me abt tpcs which should i concntrate more f sec a n b
    hey friend we cannot predict what might come.
    you need to cover all syllabus topics with there formulae and procedure.
    i can suggest you some topics
    boats and stream
    probability mostly question with card deck and bags with colored balls
    number series i.e A.P, G.P, H.P.
    speed distance and time.
    clock calender and blood realation
    we faced these type of questions at our time with some general english.
    dont worry, section A is pretty easy
    worry about sec B and C which will improve ur rank.
    all the best prepare hard.
  • Pushpendra2911
    Pushpendra2911
    aman123
    heyy, as i have left with only 15 days so can u help me abt tpcs which should i concntrate more f sec a n b
    well where are you?
    if u are at pune u have a good option for preparation.
    from sunbeam you can go predac they provide class preparation for the same.
    u can go for it.
    they cover preparation of all sections.
    well you can do it by your own.
    i did it because i was not aware of such type of preparation course.
    decision is ur .
    prepare well all the best.
  • aman123
    aman123
    Pushpendra2911
    well where are you?
    if u are at pune u have a good option for preparation.
    from sunbeam you can go predac they provide class preparation for the same.
    u can go for it.
    they cover preparation of all sections.
    well you can do it by your own.
    i did it because i was not aware of such type of preparation course.
    decision is ur .
    prepare well all the best.
    thnx..bro..i am in ambala city(near chd.) i am preparing myself only...little bit worried abt admsn....notng else.
  • aman123
    aman123
    Pushpendra2911
    well where are you?
    if u are at pune u have a good option for preparation.
    from sunbeam you can go predac they provide class preparation for the same.
    u can go for it.
    they cover preparation of all sections.
    well you can do it by your own.
    i did it because i was not aware of such type of preparation course.
    decision is ur .
    prepare well all the best.
    hello bro...thnx fr ur guidance for c-cat. i have got 36 rank in c-cat... and i will surely get acts pune...but want to knw about its placement for dac course...is it good??? what r chances....

You are reading an archived discussion.

Related Posts

Im a first year electrical student and i need help to construct a circuit to demodulate modulated AM signal. Please kindly helps if you have any idea about what simple...
A team of engineering students in France designed novel energy-producing wooden bikes from trash which were employed to power a film festival being screened at St. Étienne. This project commenced...
Priceton University scientists have developed a bionic year that hears much better than that of a normal human’s, and it was printed off a 3D printer. We recently had 3D...
CEan Conqueror is an known name to almost every CEan, but how many of us know him a little more than his awesome job. Me, and Abhishek Rawal got a...
what is the abbreviation of java in programming language?