|
|
file
when you call the function on line 91?main()
, then function definitions.
|
|
|
|
char[maxStringLength] file = openFile();
|
|
#include <cstring>
are you saying to not put using namespace std; ? |
std
namespace into the global namespace, which can cause naming conflicts - which defeats the purpose of having namespaces. The std namespace is huge, it has the entire STL inside it - all those classes, containers, templates, algorithms etc.std::
to the many things in the Standard Template Library.Could it be That file is never initialized? On line 91, you create a copy of file for openfile function. Parameters to functions create a copy of the variable to work with which goes out of scope when the function call finishes. http://www.cplusplus.com/doc/oldtutorial/functions2/ If you want to , follow theideasman suggestion and make openFile function return char[] file then call it like so char[maxStringLength] file = openFile(); And return file from within openFile method. Or you can pass a reference to file from Main like so 1 2 3 4 5 // function definition void openFile(char[]& file){...} //call method openFile(file); |
> make openFile function return char[] file then call it like so > char[maxStringLength] file = openFile(); afaik, you can't do that in c++ > On line 91, you create a copy of file for openfile function no, you pass the memory address of the first element of the array. Then thing is, in your function you lose that address at line 39 Use
By the way, you are missing #include <cstring> |
|
|
|
|