I have an array, which i want it common to both the f1.cpp and f2.cpp .

since f1.cpp will be used to store some values in it and f2.cpp has to use it for some other computations , is there any way i can share these 2 variables .

well i initially thought of files , but they dont completely solve my problem.

Recommended Answers

All 3 Replies

Create a header file with: extern int array[]; in it and include the header in the .cpp file without the array declaration..

i didnt completely get u ..

U mean to say
insitlaly i create a header file like

#include<shared_data>
extern int array[];


and then in normal code , i should directly use array ; ?

Will the data stored by the first program into this array can be used by another program .. ?

yes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.