You need a .h file that you include in both files, containing the following.
Call it separate.h
Code:
#ifdef SEPARATE_H_INCLUDED
#define SEPARATE_H_INCLUDED
//////////////////////////////////////////////////////////////////////////
class LIBS
{
private:
char HABlib[100];
public:
void setLIBS(int argc, char *argv[])
{
strcpy(HABlib,"test");
}
char* getHABlib(void) {return HABlib;} //return the ADDRESS of HABlib
};
//////////////////////////////////////////////////////////////////////////
extern LIBS L;
//////////////////////////////////////////////////////////////////////////
#endif
Then the two sources are
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
#include <errno.h>
#include <iostream>
#include "separate.h" // the file created above
using namespace std;
void funct_correlation(void);
//////////////////////////////////////////////////////////////////////////
// Create an instance of your object
LIBS L;
//////////////////////////////////////////////////////////////////////////
int main( int argc, char *argv[] )
{
L.setLIBS(argc,argv);
printf("HAB=%s\n", L.getHABlib() ); //print string at location of address
funct_correlation();
return 0;
} //end main
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
#include <errno.h>
#include <iostream>
#include "separate.h" // the file created above
using namespace std;
//////////////////////////////////////////////////////////////////////////
void funct_correlation(void)
{
char HL[100];
strcpy( HL, L.getHABlib() );
printf("HAB from funct=%s\n", HL ); //print string at location of address
return;
}