Hi all, I'm trying to write to a file using a global variable. For example....
However when I compile I get the multiple definition of `test' error for each source file. Does anyone know how I can sort this out? Thanx.Code:/* prog1.cpp */ #include "header.h" ofstream out; out.open(test,ios::app); out << "Prog1 " << endl; out.close(); /* prog2.cpp */ #include "header.h" ofstream out; out.open(test,ios::app); out << "Prog2 " << endl; out.close(); /* header.h */ char test[MAX_PATH]="file.txt";




Reply With Quote