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 Goenkause interface
-
Pushpendra2911
hello nayan please elaborate the interface . I am totally blank what you are talking about. What kind of interface we are talking here.Nayan Goenkause interface -
Nayan GoenkaThere 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
dude i am a clean C programmer have no idea about java. Do you have any idea in C.Nayan GoenkaThere 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. -
rahul69
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:Pushpendra2911i 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.
#include"a.c"
Although this is not an efficient method, but it will workđ .
Good Luck , any doubts are welcomedđ . -
Pushpendra2911thanks 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 SharmaPushpendra2911thanks 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
well thanx for your reply vishalVishal0203Create 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
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 Sharmai'd like to see a example code!
-
Pushpendra2911
my code is little complicated in order to share.Vishal0203i'd like to see a example code!
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
hello pushpendra...mself aman...need to talk to you...regardng cdac ccat....can i get ur contact no. or email id????? mine isPushpendra2911my 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. -
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.aman123hello pushpendra...mself aman...need to talk to you...regardng cdac ccat....can i get ur contact no. or email id????? mine is #-Link-Snipped-# -
aman123
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...Pushpendra2911yes 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
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 bPushpendra2911yes 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. -
Pushpendra2911
hey friend we cannot predict what might come.aman123heyy, 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
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
well where are you?aman123heyy, 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
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
thnx..bro..i am in ambala city(near chd.) i am preparing myself only...little bit worried abt admsn....notng else.Pushpendra2911well 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
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....Pushpendra2911well 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.
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?